Skip to content

Commit

Permalink
Moved get_type_hints() to the 3.9 level
Browse files Browse the repository at this point in the history
This function gained an extra parameter, "include_extras", in Python 3.9, and this parameter is provided by the typing_extensions implementation.
  • Loading branch information
agronholm authored and asottile committed Sep 24, 2022
1 parent b34a282 commit 89f5dfb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions reorder_python_imports.py
Expand Up @@ -419,7 +419,7 @@ def _fix_file(

# GENERATED VIA generate-typing-rewrite-info
# Using:
# flake8-typing-imports==1.12.0
# flake8-typing-imports==1.13.0
# mypy-extensions==0.4.3
# typing-extensions==4.3.0
REPLACES[(3, 6)].update((
Expand All @@ -434,7 +434,6 @@ def _fix_file(
'typing_extensions=typing:TYPE_CHECKING',
'typing_extensions=typing:Text',
'typing_extensions=typing:Type',
'typing_extensions=typing:get_type_hints',
))
REPLACES[(3, 7)].update((
'mypy_extensions=typing:NoReturn',
Expand All @@ -456,6 +455,7 @@ def _fix_file(
))
REPLACES[(3, 9)].update((
'typing_extensions=typing:Annotated',
'typing_extensions=typing:get_type_hints',
))
REPLACES[(3, 10)].update((
'typing_extensions=typing:Concatenate',
Expand Down
2 changes: 2 additions & 0 deletions testing/generate-typing-rewrite-info
Expand Up @@ -17,13 +17,15 @@ else:

# --- typing_extensions notes ---
# https://github.com/python/typing_extensions#other-notes-and-limitations
# - Starting with Python 3.9, get_type_hints() has the include_extra parameter
# - get_origin and get_args lack support for Annotated in Python 3.8
# and lack support for ParamSpecArgs and ParamSpecKwargs in 3.9.
# - Starting with 3.11, NamedTuple and TypedDict can inherit from Generic
# - @final was changed in Python 3.11 to set the .__final__ attribute
# - @overload was changed in Python 3.11 to make function overloads
# introspectable at runtime.
CUSTOM_TYPING_EXT_SYMBOLS = {
(3, 9): {'get_type_hints'},
(3, 10): {'get_origin', 'get_args'},
(3, 11): {'NamedTuple', 'TypedDict', 'final', 'overload'},
}
Expand Down

0 comments on commit 89f5dfb

Please sign in to comment.