-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
TYP: Enable pyright's reportInconsistentConstructor #54398
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
TYP: Enable pyright's reportInconsistentConstructor #54398
Conversation
@@ -189,9 +189,6 @@ def ndim(self) -> int: | |||
|
|||
|
|||
class Constant(Term): | |||
def __init__(self, value, env, side=None, encoding=None) -> None: | |||
super().__init__(value, env, side=side, encoding=encoding) |
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.
Should not be needed, just calls the parent constructor (and uses value
instead of name
)
@@ -573,7 +573,7 @@ class PeriodProperties(Properties): | |||
class CombinedDatetimelikeProperties( | |||
DatetimeProperties, TimedeltaProperties, PeriodProperties | |||
): | |||
def __new__(cls, data: Series): | |||
def __new__(cls, data: Series): # pyright: ignore[reportInconsistentConstructor] |
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.
The parent __init__
expect orig
as a second argument. Just ignoring the error as the comment indicates that this class is never "really" instantiated.
Renaming the arguments ( |
AFAICT none of the affected places are public, so I don't think thats a problem |
@@ -732,6 +732,7 @@ include = ["pandas", "typings"] | |||
exclude = ["pandas/tests", "pandas/io/clipboard", "pandas/util/version"] | |||
# enable subset of "strict" | |||
reportDuplicateImport = true | |||
reportInconsistentConstructor = true |
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.
In a follow up, could we enable strict mode and then turn off the checks that don't pass (with todos) or are not relevant like we did with mypy?
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 could enable strict and disable many of its rules (and I think we had that in the past). I think the pyright maintainer recommended that we prioritize enabling reportGeneralTypeIssues (we have a large blacklist in pyright_reportGeneralTypeIssues.json) before enabling strict as it also changes some of its behavior.
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.
Okay sounds good
@@ -1,4 +1,3 @@ | |||
# this becomes obsolete when reportGeneralTypeIssues can be enabled in pyproject.toml |
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.
Pyright uses a stricter JSON parser - comments are not part of the JSON syntax.
(There are much newer versions of pyright but there are too many things we would need to change at the moment.)
Thanks @twoertwein |
reportInconsistentConstructor checks that
__new__
and__init__
should be consistent (argument names and their types)