-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Should we error on "not-recommended" behavior in static typing tests ? #16891
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
Comments
I agree with this. I think we had a similar discussion before. Rather be strict in type annotations to signal the code we want people to write, than to provide typing for every bit of valid code. |
I share your sentiment. |
Some previous discussion: numpy/numpy-stubs#12 So far we've come down on the side of strictness; though I imagine decisions will continue to be made on a case-by-case basis. I think an important thing is documenting the decisions so that we don't end up discussing the same points endlessly, so far I have been doing that here: https://github.com/numpy/numpy/blob/master/numpy/typing/__init__.py#L25 |
Thanks for the suggestion, I have added the doc changes here : #16917. |
…., ...})` syntax Removed per the discussion in numpy#16891
This discussion stems from here : #16622 (comment)
The numpy documentation says the following about instantiating the dtype object using "{'field1': ..., 'field2': ..., ...}":
"This usage is discouraged, because it is ambiguous with the other dict-based construction method. If you have a field called ‘names’ and a field called ‘formats’ there will be a conflict."
I think static typing is a good place to catch not just "wrong" types used, but also to catch early such discouraged usage in numpy. So, IMO we should have the type checker error on such behavior. WDYT ?
The text was updated successfully, but these errors were encountered: