Open bschnurr opened 1 year ago
Pretty sure we use __new__
instead so that we can make both pyright and mypy happy:
might be worth revisiting if that's still necessary -- I can't remember which type checker preferred new to init
pyright seems to prefer init.. users not getting correct signatures anymore
I'll have to revert pylance back to the old stubs https://github.com/typeddjango/django-stubs for now
Yeah, we could probably change the types to use __init__
instead of __new__
@bschnurr I've refactored the type definitions to use __init__
in #139, but Pylance is having issues with understanding foreign keys. Mypy seems to work fine though and we do have better autocomplete.
reveal_type(comment.nullable_user_type)
mypy: Revealed type is "Union[tests.trout.models.User, None]"
Pylance: Type of "comment.nullable_user_type" is "_M@ForeignKey | None"
Pylance/pyright have been updated to look at __new__
https://github.com/microsoft/pylance-release/issues/3401