Skip to content
This repository was archived by the owner on Jun 10, 2020. It is now read-only.

Add typing_extensions as a dependency #60

Closed
person142 opened this issue Apr 19, 2020 · 4 comments
Closed

Add typing_extensions as a dependency #60

person142 opened this issue Apr 19, 2020 · 4 comments

Comments

@person142
Copy link
Member

The typing_extensions module contains backports of new typing features for earlier versions of Python. It is understood by type checkers like Mypy and Pyre. In #59 it is proposed that we add it as a dependency, which I think is a good idea. Beyond just that PR, some potential benefits are:

  • Using Literal to better type specific (but fairly common) overloads, e.g.
    np.array(..., dtype="float")
  • Protocol might be a good way to approach typing ArrayLike
  • Using TypedDict to better describe complex dtypes.

I imagine that the biggest concern would be forcing it to be a hard dependency of NumPy should the stubs be moved there, but I believe we can avoid that.

  • If everything stays stubs only, then it's not a problem

  • If we do add annotations to source files, we can still work around it with constructs like

    from typing import TYPE_CHECKING
    
    if TYPE_CHECKING:
        from typing_extensions import Literal
    
    x: 'Literal[1]' = 1  # Or use `from __future__ import annotations` post 3.8
    ...

Objections? In the absence of them we'll move forward with including it.

@rgommers
Copy link
Member

Sounds like a good idea to me

@BvB93
Copy link
Member

BvB93 commented Apr 20, 2020

A separate pull request has just been created for the addition of typing_extensions (#63).

@person142
Copy link
Member Author

Thanks. I’ll give people a little bit longer to raise any objections here, and then we’ll move forward.

@person142
Copy link
Member Author

Closed by #63.

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

No branches or pull requests

3 participants