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: Replace the module-level __getattr__ with explicit type annotations #17367

Closed
2 tasks done
BvB93 opened this issue Sep 23, 2020 · 5 comments · Fixed by #17406
Closed
2 tasks done

ENH: Replace the module-level __getattr__ with explicit type annotations #17367

BvB93 opened this issue Sep 23, 2020 · 5 comments · Fixed by #17406

Comments

@BvB93
Copy link
Member

BvB93 commented Sep 23, 2020

The main __init__.pyi file currently contains a module-level __getattr__() function and
,while quite convenient due to the incomplete nature of the stubs, its use is rather unsafe:
any getattr(numpy, str(...)) operation is currently considered valid by static type checkers.

For this reason a set of placeholder stubs was recently added to generic/ndarray (#17188) and
all public module (#17104). All that remains is to do the same for the main __init__.pyi file.

TODO

@BvB93 BvB93 added this to the 1.20.0 release milestone Sep 23, 2020
@BvB93 BvB93 changed the title ENH: Replace the module-level __getattr__ with explicit type annotation ENH: Replace the module-level __getattr__ with explicit type annotations Sep 23, 2020
@ikedaosushi
Copy link

I'd like to tackle it if no problem.

@BvB93
Copy link
Member Author

BvB93 commented Sep 23, 2020

Sure, feel free to go ahead.

@junjunjunk
Copy link

junjunjunk commented Sep 30, 2020

@BvB93
May I ask you a question to make sure I'm okay?
The second task means that add describes in __init__.pyi as below?

DataSource: Any
... (other objects)
who: Any

@BvB93
Copy link
Member Author

BvB93 commented Sep 30, 2020

The second task means that add describes in init.pyi as below?

Yes, exactly like that.
The same as what has been done in the likes of https://github.com/numpy/numpy/blob/master/numpy/char.pyi.

@junjunjunk
Copy link

Thank you for your detailed reply.
I issued PR.

mattip added a commit that referenced this issue Oct 1, 2020
ENH: Replace the module-level `__getattr__` with explicit type annotations #17367
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants