-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
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
Fix typing of deprecated aliases #44
Conversation
This fixes type hints in Pylance. The module `__getattr__` throws off its checking of what types are actually available. This hides the `__getattr__` from type checkers
commands2/subsystem.py
Outdated
CommandScheduler.getInstance().registerSubsystem(instance) | ||
return instance | ||
if not TYPE_CHECKING: | ||
def __new__(cls, *arg, **kwargs) -> "Subsystem": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems wrong. We should return typing.Self
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. But typing.Self was added in 3.11 according to https://docs.python.org/3/library/typing.html#typing.Self
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're already using typing_extensions in command, so let's just use it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, swapped it over
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with nit
Co-authored-by: David Vo <auscompgeek@users.noreply.github.com>
This fixes type hints in Pylance. The module
__getattr__
throws off its checking of what types are actually available.This hides the
__getattr__
from type checkers