Skip to content

Commit

Permalink
Merge pull request #179 from asottile/3-13-symbols
Browse files Browse the repository at this point in the history
regenerate typing symbols for 3.13
  • Loading branch information
asottile authored Oct 11, 2024
2 parents 3e2e305 + ebb176c commit 4f58fdc
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 5 deletions.
23 changes: 18 additions & 5 deletions bin/build-generated
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,22 @@ def get_tag_list(repo: str) -> tuple[str, ...]:
PROG = '''\
import json
import sys
globs = {'__name__': 'typing'}
exec(compile(sys.stdin.read(), '<typing>', 'exec'), globs)
_typing = type('typing', (), globs)
print(json.dumps([
import types
_typing = types.ModuleType('typing')
exec(compile(sys.stdin.read(), '<typing>', 'exec'), _typing.__dict__)
lst = []
# populate lazy attributes (Match, Pattern, etc.)
if sys.version_info >= (3, 13):
for k in _typing.__all__:
getattr(_typing, k)
else:
lst.extend(_typing.io.__all__)
lst.extend(_typing.re.__all__)
lst.extend([
k for k, v in vars(_typing).items()
if k not in {'io', 're'}
if k in _typing.__all__ or (
Expand All @@ -33,7 +45,8 @@ print(json.dumps([
# but export all things that have __module__ == 'typing'
getattr(v, '__module__', None) == _typing.__name__
)
] + _typing.io.__all__ + _typing.re.__all__))
])
print(json.dumps(lst))
'''


Expand Down
43 changes: 43 additions & 0 deletions flake8_typing_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ def parse(cls, s: str) -> Version:
SYMBOLS.append((Version(3, 8, 16), SYMBOLS[-1][1]))
SYMBOLS.append((Version(3, 8, 17), SYMBOLS[-1][1]))
SYMBOLS.append((Version(3, 8, 18), SYMBOLS[-1][1]))
SYMBOLS.append((Version(3, 8, 19), SYMBOLS[-1][1]))
SYMBOLS.append((Version(3, 8, 20), SYMBOLS[-1][1]))
SYMBOLS.append((
Version(3, 9, 0), frozenset((
'AbstractSet', 'Annotated', 'Any', 'AnyStr', 'AsyncContextManager',
Expand Down Expand Up @@ -227,6 +229,8 @@ def parse(cls, s: str) -> Version:
SYMBOLS.append((Version(3, 9, 16), SYMBOLS[-1][1]))
SYMBOLS.append((Version(3, 9, 17), SYMBOLS[-1][1]))
SYMBOLS.append((Version(3, 9, 18), SYMBOLS[-1][1]))
SYMBOLS.append((Version(3, 9, 19), SYMBOLS[-1][1]))
SYMBOLS.append((Version(3, 9, 20), SYMBOLS[-1][1]))
SYMBOLS.append((
Version(3, 10, 0), frozenset((
'AbstractSet', 'Annotated', 'Any', 'AnyStr', 'AsyncContextManager',
Expand Down Expand Up @@ -261,6 +265,8 @@ def parse(cls, s: str) -> Version:
SYMBOLS.append((Version(3, 10, 11), SYMBOLS[-1][1]))
SYMBOLS.append((Version(3, 10, 12), SYMBOLS[-1][1]))
SYMBOLS.append((Version(3, 10, 13), SYMBOLS[-1][1]))
SYMBOLS.append((Version(3, 10, 14), SYMBOLS[-1][1]))
SYMBOLS.append((Version(3, 10, 15), SYMBOLS[-1][1]))
SYMBOLS.append((
Version(3, 11, 0), frozenset((
'AbstractSet', 'Annotated', 'Any', 'AnyStr', 'AsyncContextManager',
Expand Down Expand Up @@ -291,6 +297,10 @@ def parse(cls, s: str) -> Version:
SYMBOLS.append((Version(3, 11, 4), SYMBOLS[-1][1]))
SYMBOLS.append((Version(3, 11, 5), SYMBOLS[-1][1]))
SYMBOLS.append((Version(3, 11, 6), SYMBOLS[-1][1]))
SYMBOLS.append((Version(3, 11, 7), SYMBOLS[-1][1]))
SYMBOLS.append((Version(3, 11, 8), SYMBOLS[-1][1]))
SYMBOLS.append((Version(3, 11, 9), SYMBOLS[-1][1]))
SYMBOLS.append((Version(3, 11, 10), SYMBOLS[-1][1]))
SYMBOLS.append((
Version(3, 12, 0), frozenset((
'AbstractSet', 'Annotated', 'Any', 'AnyStr', 'AsyncContextManager',
Expand All @@ -316,6 +326,39 @@ def parse(cls, s: str) -> Version:
'runtime_checkable',
)),
))
SYMBOLS.append((Version(3, 12, 1), SYMBOLS[-1][1]))
SYMBOLS.append((Version(3, 12, 2), SYMBOLS[-1][1]))
SYMBOLS.append((Version(3, 12, 3), SYMBOLS[-1][1]))
SYMBOLS.append((Version(3, 12, 4), SYMBOLS[-1][1]))
SYMBOLS.append((Version(3, 12, 5), SYMBOLS[-1][1]))
SYMBOLS.append((Version(3, 12, 6), SYMBOLS[-1][1]))
SYMBOLS.append((Version(3, 12, 7), SYMBOLS[-1][1]))
SYMBOLS.append((
Version(3, 13, 0), frozenset((
'AbstractSet', 'Annotated', 'Any', 'AnyStr', 'AsyncContextManager',
'AsyncGenerator', 'AsyncIterable', 'AsyncIterator', 'Awaitable',
'BinaryIO', 'ByteString', 'Callable', 'ChainMap', 'ClassVar',
'Collection', 'Concatenate', 'Container', 'ContextManager',
'Coroutine', 'Counter', 'DefaultDict', 'Deque', 'Dict', 'Final',
'ForwardRef', 'FrozenSet', 'Generator', 'Generic', 'Hashable', 'IO',
'ItemsView', 'Iterable', 'Iterator', 'KeysView', 'List', 'Literal',
'LiteralString', 'Mapping', 'MappingView', 'Match', 'MutableMapping',
'MutableSequence', 'MutableSet', 'NamedTuple', 'Never', 'NewType',
'NoDefault', 'NoReturn', 'NotRequired', 'Optional', 'OrderedDict',
'ParamSpec', 'ParamSpecArgs', 'ParamSpecKwargs', 'Pattern', 'Protocol',
'ReadOnly', 'Required', 'Reversible', 'Self', 'Sequence', 'Set',
'Sized', 'SupportsAbs', 'SupportsBytes', 'SupportsComplex',
'SupportsFloat', 'SupportsIndex', 'SupportsInt', 'SupportsRound',
'TYPE_CHECKING', 'Text', 'TextIO', 'Tuple', 'Type', 'TypeAlias',
'TypeAliasType', 'TypeGuard', 'TypeIs', 'TypeVar', 'TypeVarTuple',
'TypedDict', 'Union', 'Unpack', 'ValuesView', 'assert_never',
'assert_type', 'cast', 'clear_overloads', 'dataclass_transform',
'final', 'get_args', 'get_origin', 'get_overloads',
'get_protocol_members', 'get_type_hints', 'is_protocol',
'is_typeddict', 'no_type_check', 'no_type_check_decorator', 'overload',
'override', 'reveal_type', 'runtime_checkable',
)),
))
# END GENERATED
VERSIONS = frozenset(version for version, _ in SYMBOLS)

Expand Down

0 comments on commit 4f58fdc

Please sign in to comment.