-
-
Notifications
You must be signed in to change notification settings - Fork 521
Description
Bug report
What's wrong
For some custom managers in our codebase we get an incorrect typing error for calls to .using():
error: Argument 1 to "using" of "SomeManager" has incompatible type "str"; expected "_SpecialForm" [arg-type]
Stepping through the plugin this appears to stem from this call to helpers.copy_method_to_another_class. That calls bind_or_anaylyze_type for each argument, which again ends up calling api.lookup_fully_qualified_or_none("django.db.models.query.Optional"). This is where the _SpecialCase comes into play, because the type of the alias parameter is an instance of UnboundType up to this point.
Has anyone else seen this? I've been unable to create an isolated reproducer and I'm not familiar enough with mypy to understand what's really going on here. Would love to get this fixed though, as it's causing us use a lot of # type: ignore comments! I'll keep digging, but would love some help to get this fixed.
How is that should be
The type signature should be kept as def (self: _QS, alias: Optional[str]) -> _QS.
System information
- OS: macOS 12.3.1 and Ubuntu 20.04
pythonversion: 3.9.9 an 3.10.2djangoversion: 3.2.13mypyversion: 0.950django-stubsversion: latest master (e221f0e0533c98417ed726cba764b5f6282442f8)django-stubs-extversion: latest master (e221f0e0533c98417ed726cba764b5f6282442f8)