-
-
Notifications
You must be signed in to change notification settings - Fork 11.2k
TYP: Type default values in stubs in numpy/ma
#29531
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.
I like the libcst approach, and the ones I checked seem to all be correct.
Technically speaking, this has little to do with static typing, but can be very helpful for IDE introspection, which is also one of the main advantages of annotations, so I suppose it's fine to keep the TYP:
label.
For most defaults I can see that they can be useful. But in some cases, like out=None
, I'm not if the defaults are actually helpful. Because without annotations, just having out=None
doesn't give you any additional information about how it can be used. It could even be a bit confusing this way if some parameters use =None
and others =np._NoValue
(i.e. =...
), especially if you consider that the documentation of _NoValue
often incorrectly says it defaults to None
. That could be confusing because it appears to be inconsistent.
Anyway, it probably doesn't matter much, so I'm fine with keeping those =None
. Removing them now would mean we'd have to add them back in again once we add the annotations.
Thanks |
Making some progress towards #28428
Similar PR in pandas: pandas-dev/pandas-stubs#1293
I've done this based on work started in https://gist.github.com/yangdanny97/170f82ee5389584f8b6292bc4ea9c24d, we're looking at open-sourcing a reusable tool to do this automatically where possible:
= ...
...
inThe ones in this PR, I checked manually, and they look correct to me