Skip to content

Commit bd212bc

Browse files
Remove type aliases that are long supported (#16039)
Some builtin aliases are available for all python versions that we support. So, there's no need to check them in `semanal`: https://github.com/python/mypy/blob/8738886861682e0d168ea321c2cc6ee5b566cb8b/mypy/semanal.py#L673-L689 --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 8738886 commit bd212bc

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

mypy/nodes.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -138,18 +138,7 @@ def set_line(
138138

139139
# This keeps track of the oldest supported Python version where the corresponding
140140
# alias source is available.
141-
type_aliases_source_versions: Final = {
142-
"typing.List": (2, 7),
143-
"typing.Dict": (2, 7),
144-
"typing.Set": (2, 7),
145-
"typing.FrozenSet": (2, 7),
146-
"typing.ChainMap": (3, 3),
147-
"typing.Counter": (2, 7),
148-
"typing.DefaultDict": (2, 7),
149-
"typing.Deque": (2, 7),
150-
"typing.OrderedDict": (3, 7),
151-
"typing.LiteralString": (3, 11),
152-
}
141+
type_aliases_source_versions: Final = {"typing.LiteralString": (3, 11)}
153142

154143
# This keeps track of aliases in `typing_extensions`, which we treat specially.
155144
typing_extensions_aliases: Final = {

mypy/semanal.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,10 @@ def add_builtin_aliases(self, tree: MypyFile) -> None:
680680
"""
681681
assert tree.fullname == "typing"
682682
for alias, target_name in type_aliases.items():
683-
if type_aliases_source_versions[alias] > self.options.python_version:
683+
if (
684+
alias in type_aliases_source_versions
685+
and type_aliases_source_versions[alias] > self.options.python_version
686+
):
684687
# This alias is not available on this Python version.
685688
continue
686689
name = alias.split(".")[-1]

0 commit comments

Comments
 (0)