Skip to content

Examples shouldn't use typing_extensions imports for stable typing features #1986

Open
@smheidrich

Description

@smheidrich

Description

There are a few code examples in the docs which import things from typing_extensions that are by now available in Python's typing standard library module:

List

from typing_extensions import Never

from typing_extensions import ParamSpec

... and 4 more occurrences in reference/generics.rst.

from typing_extensions import Protocol

... and 4 more occurrences in reference/protocols.rst.

from typing_extensions import assert_type

It probably makes sense to use typing imports for all of these instead, possibly with the typing_extensions alternative mentioned.

How to fix?

What is the policy for these? Should they just be replaced with bare typing imports or something more like

from typing import Protocol # or from typing_extensions for Python < 3.8

?
I haven't seen the latter in any of the other imports, which just import from typing without comment (EDIT: at least not in the code itself, but usually it is mentioned as an alternative for older versions somewhere around the code), but who knows...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions