Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Adding protocols and aliases from _typeshed to typing-extensions #6

Closed
@srittau

Description

@srittau

This was already partly discussed in #9. I think we should start adding some commonly used protocols, type aliases, and other features from _typeshed to typing_extensions so they are available at runtime. This would prevent awkward guarded imports at runtime.

I would suggest to put this into a submodule to separate those types from the "backports and experimental features" that are added to the main namespace. Suggestion: typing_extensions.ext. For a start I would suggest to add the following:

  • Some simple dunder protocols: SupportsNext, SupportsAnext, SupportsTrunc, SupportsDivMod, SupportsRDivMod. (I would hold off on protocols like SupportsAdd for now as they are using Any.)
  • SupportsGetItem, SupportsItems and SupportsKeysAndGetItem
  • The path aliases StrPath, BytesPath. StrOrBytesPath probably doesn't have much value over StrPath | BytesPath.
  • Some simple I/O protocols: SupportsRead, SupportsReadline, SupportsWrite

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions