-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
small typing fixes #39348
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
small typing fixes #39348
Conversation
@@ -91,7 +91,7 @@ | |||
Suffixes = Tuple[str, str] | |||
Ordered = Optional[bool] | |||
JSONSerializable = Optional[Union[PythonScalar, List, Dict]] | |||
Axes = Collection |
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.
do we actually use this? grepping for ": Axes" im mostly (only?) seeing matplotlib types
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.
It's in the type signature for DataFrame.__init__
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 don't want to generically type like this
@jbrockmendel Only failure was in some IO testing. Do you want to merge in anyway? |
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 don't want to generically type
@jreback Can you explain. The changes I made were to change
and in So aren't my changes not generically typing by specifying that you can use any type? |
the Any for the collections should be more specific on what actually is allowed |
@jreback That's non-trivial In
So since an Furthermore, the correction in this PR is to change We could also change Let me know. |
@jreback pinging you on #39348 (comment) |
thanks @Dr-Irv generally we don't want to use Any if at all possible, even generically, but ok |
FYI we have an issue related to this. #30539 mypy has strictness flags that you can enable at milestones throughout the typing journey. Requiring type parameters is often requested during review. Adding Any just to satisfy the type checker shouldn't be necessary, as we in general prefer to leave untyped for now to indicate that we have not yet established what types are permitted. Just like Optional, Any is a confusingly named alias. Any means that the type checker will accept any type without reporting errors and is often used in heavily dynamic code that is difficult to statically check. If indeed, the code accepts any type, the type should be object not Any. Mypy will then report errors if we try to do anything with that type that is not available on all objects. for instance, if we do a len(x), Any would not report any errors, but using object would give us with mypy we can turn these strictness flags on/off globally on for individual modules so can we please, not add Any just for pyright at this stage and maybe discuss perhaps locking down the files that pass |
@simonjayhawkins That's fair. We're all learning the best way of doing this as we move forward. It might be worth having a page in the developer's documentation section about the "rules" (such as avoiding |
Some very small fixes to typing declarations to fix some errors found by
pyright
Should not affect running code at all. mypy tests passed locally.