Skip to content
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

ENH: Improve the placeholder annotations for the main numpy namespace (part 2) #18780

Merged
merged 2 commits into from
Apr 16, 2021

Conversation

BvB93
Copy link
Member

@BvB93 BvB93 commented Apr 15, 2021

Follow up on #18765.

This PR makes two new sets of improvements to the placeholder annotations:

  • Replaces the Type[Any] annotations of the classes with explicit class definitions. The former can cause issues as mypy does not allow one to inherit from such objects (e.g. MAINT: Add inline type hintings for stats.qmc scipy/scipy#13833 (comment)).
  • Replaces the Callable[..., Any] annotation of the C-based functions with explicit function definitions. The relevant signatures were herein adapted from the functions' docstring.

Bas van Beek added 2 commits April 15, 2021 13:44
Use explicitly defined classes rather than annotating them as `Type[Any]`.
The latter currently causes issues with mypy, which does not allow it to be used as a baseclass (because reasons?)
All new function definitions based on the respective functions' docstring
def concatenate(__a, axis=..., out=..., dtype=..., casting=...): ...
def copyto(dst, src, casting=..., where=...): ...
def datetime_as_string(arr, unit=..., timezone=..., casting=...): ...
def datetime_data(__dtype): ...
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The double leading underscore is used for denoting position-only arguments per PEP 484. The newer /-based syntax introduced in PEP 570 is, unfortunatelly, not yet supported by mypy for python versions prior to python 3.8.

@charris charris merged commit ea0bf54 into numpy:main Apr 16, 2021
@charris
Copy link
Member

charris commented Apr 16, 2021

Thanks Bas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants