We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(Based on #3111)
This fails with Argument 1 to "__new__" of "object" has incompatible type C[T]; expected "object"
Argument 1 to "__new__" of "object" has incompatible type C[T]; expected "object"
T = TypeVar('T') class C(Generic[T]): def __new__(cls, foo: T) -> 'C[T]': obj = object.__new__(cls) return obj def set(self, x: T) -> None: pass
Edit: deleted my own incorrect interpretation.
The text was updated successfully, but these errors were encountered:
This also happens when __init__ is present and has non-zero arguments in the signature:
__init__
class C: def __init__(self, x: int) -> None: pass def __new__(cls, *args) -> 'C': obj = object.__new__(cls) # E: Argument 1 to "__new__" of "object" has incompatible type "C"; expected "object" return obj
However, this passes:
class C: def __new__(cls) -> 'C': obj = object.__new__(cls) return obj
Somehow the presence of arguments in the signature prevents mypy from matching the class object to the expected object type.
object
Sorry, something went wrong.
#4190 is a dupe of this but I'm closing this one because that one got categorized
No branches or pull requests
(Based on #3111)
This fails with
Argument 1 to "__new__" of "object" has incompatible type C[T]; expected "object"
Edit: deleted my own incorrect interpretation.
The text was updated successfully, but these errors were encountered: