Skip to content

ENH: Improve the placeholder annotations for the main numpy namespace#18765

Merged
charris merged 5 commits intonumpy:mainfrom
BvB93:placeholder
Apr 13, 2021
Merged

ENH: Improve the placeholder annotations for the main numpy namespace#18765
charris merged 5 commits intonumpy:mainfrom
BvB93:placeholder

Conversation

@BvB93
Copy link
Copy Markdown
Member

@BvB93 BvB93 commented Apr 13, 2021

This PR improves the placeholder type annotations for the main numpy namespace,
namelly to provide something a bit more oncrete than just plain Any.

The improvements can be divided into four general categories:

  • Miscelanous objects (e.g. ScalarType): Have been fully annotated.
  • Classes (e.g. iinfo): Have been annotated as Type[Any].
  • Python-based functions (e.g. angle): Have been replaced with proper (unannotated) functions, constructed with the help of inspect.signature.
  • C-based functions (e.g. arange): Have been annotated as Callable[..., Any] as we can't (ab)use inspect.signature here.

Applying similar improvements to the various other namespaces is considered beyond the scope of this PR and
reserved for future work.

@charris
Copy link
Copy Markdown
Member

charris commented Apr 13, 2021

Thanks Bas. Is there any way to break some of the long lines in some of the annotations?

@BvB93 BvB93 deleted the placeholder branch April 13, 2021 17:39
@BvB93
Copy link
Copy Markdown
Member Author

BvB93 commented Apr 13, 2021

Sure, especially with the bigger functions (e.g. np.genfromtxt) we can just spread the function definition over multiple lines.

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.

2 participants