Skip to content

Port typeshed's tests/check_new_syntax.py here #80

@Akuli

Description

@Akuli

Typeshed currently has a script that checks a bunch of things that belong here IMO: https://github.com/python/typeshed/blob/af8e37d2736d3a6fbed8f5dfad71580dd417c612/tests/check_new_syntax.py

  • Collections classes in typing: typing.Counter --> collections.Counter etc (related: Suggest using collections.abc etc, not typing (deprecated since 3.9) #46)
  • Built-in generics: List --> list etc
  • typing.(Async)ContextManager --> contextlib.Abstract(Async)ContextManager
  • Preferring typing over typing_extensions when available: typing_extensions.ClassVar --> typing.ClassVar etc
  • Union[str, int] --> str | int (Suggest using PEP 604-style union types #45)
  • Banning from collections.abc import Set, because it's confusingly different from the built-in set
  • Ordering sys.version_info checks so that the most recent version is first
  • Ban explicitly inheriting from object in Python 3-only stubs.
  • Disallow using typing.Text in Python 3-only stubs.

We should probably create one error code per Python version, so that it's easy to e.g. enable errors for not using features new in Python 3.8+. Another option would be to make the errors depend on sys.version_info (maybe too clever, would need good documentation).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions