-
Notifications
You must be signed in to change notification settings - Fork 998
Stricter types with pyright #2731
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
Conversation
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.
Not bad, but I think you did a bit too much search/replace, especially the _x parameters give important information.
This reverts commit df30901.
I fully expected some pushback on the Alternatives: class Base:
def method(arg):
return arg
# this PR - keep identical signatures
class Derived:
def method(arg):
pass
# explicit suppress
class Derived_ignore: # type:ignore[reportIncompatibleMethodOverride]
def method(_arg):
pass
# fake usage
class Derived_assign:
def method(arg):
_ = arg
# unpacking
class Derived_kwargs:
def method(*args, **kwargs):
pass |
This reverts commit c81a935.
But this is wrong !! it does not make sense to demand that positional parameters have the same name in inherited classes....I would consider that a general false positive. |
Disagree, although it's not a particularly big deal if using positional args: https://en.wikipedia.org/wiki/Liskov_substitution_principle |
Anyways, I have removed the contentious commits for another day. Do you agree with c3ed1b1 or should I revert that as well? |
…turn)" This reverts commit c3ed1b1.
I think you made that commit a separate PR, which I have approved. |
Yes, if you can't solve a problem... remove it 😆 Anyways, I think this PR I ready. |
Let me take a look. |
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, thanks.
pyright
is another type-checker that finds some things thatmypy
does not.Currently there are 42 errors in
dev
, which this PR reduces to6. EDIT: 32.Several of them are false positives from imports and
byte
/bytearray
confusion.However, many are mismatched type signatures between classes and subclasses that are easy enough to improve.
I have split different types of changes into different commits so they can be cherry-picked or reverted if desired.