-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
false-positivemypy gave an error on correct codemypy gave an error on correct codepriority-1-normaltopic-pluginsThe plugin API and ideas for new pluginsThe plugin API and ideas for new plugins
Description
On master and 0.630, the following code fails with error: Incompatible return value type (got "Foo", expected "T")
:
from dataclasses import dataclass
import typing as t
T = t.TypeVar('T', bound="Foo")
@dataclass
class Foo:
@classmethod
def make(cls: t.Type[T]) -> T:
return cls()
If I remove the dataclass annotation, it works fine.
Metadata
Metadata
Assignees
Labels
false-positivemypy gave an error on correct codemypy gave an error on correct codepriority-1-normaltopic-pluginsThe plugin API and ideas for new pluginsThe plugin API and ideas for new plugins
Projects
Milestone
Relationships
Development
Select code repository
Activity
JelleZijlstra commentedon Nov 29, 2018
cc @euresti since this seems to be due to the dataclasses plugin.
euresti commentedon Nov 29, 2018
Hmm. In my code I usually annotate this as:
But I hardly use inheritance.
Also I don't know why the decorator would break it. Does it happens with
@attr.s
?ilevkivskyi commentedon Nov 29, 2018
This works on master
ilevkivskyi commentedon Nov 29, 2018
Also this is a duplicate of #5263 that was fixed by #5646