Skip to content

Commit

Permalink
Fix ForwardRef wrapper for py 3.10.0 (shim until bpo-45166) (#6919)
Browse files Browse the repository at this point in the history
  • Loading branch information
randomir committed Jul 27, 2023
1 parent b33a795 commit 6a0038b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pydantic/_internal/_typing_extra.py
Expand Up @@ -253,7 +253,7 @@ def get_function_type_hints(
return type_hints


if sys.version_info < (3, 9, 8):
if sys.version_info < (3, 9, 8) or (3, 10) <= sys.version_info < (3, 10, 1):

def _make_forward_ref(
arg: Any,
Expand All @@ -262,11 +262,13 @@ def _make_forward_ref(
is_class: bool = False,
) -> typing.ForwardRef:
"""Wrapper for ForwardRef that accounts for the `is_class` argument missing in older versions.
The `module` argument is omitted as it breaks <3.9.8 and isn't used in the calls below.
The `module` argument is omitted as it breaks <3.9.8, =3.10.0 and isn't used in the calls below.
See https://github.com/python/cpython/pull/28560 for some background.
The backport happened on 3.9.8, see:
https://github.com/pydantic/pydantic/discussions/6244#discussioncomment-6275458.
https://github.com/pydantic/pydantic/discussions/6244#discussioncomment-6275458,
and on 3.10.1 for the 3.10 branch, see:
https://github.com/pydantic/pydantic/issues/6912
Implemented as EAFP with memory.
"""
Expand Down

0 comments on commit 6a0038b

Please sign in to comment.