diff --git a/pydantic/_internal/_typing_extra.py b/pydantic/_internal/_typing_extra.py index b576577244..21524df6a6 100644 --- a/pydantic/_internal/_typing_extra.py +++ b/pydantic/_internal/_typing_extra.py @@ -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, @@ -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. """