Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ForwardRef wrapper for py 3.10.0 (shim until bpo-45166) #6919

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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