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 on 3.12 #25

Merged
merged 1 commit into from
Dec 21, 2024
Merged

Fix ForwardRef on 3.12 #25

merged 1 commit into from
Dec 21, 2024

Conversation

PerchunPak
Copy link
Contributor

Python 3.12 added a new argument which broke the library. It also made one of the arguments keyword-only which I also fixed.

Fixes #24

@PerchunPak

This comment was marked as resolved.

@alexmojaki
Copy link
Owner

Do they not happen locally?

Comment on lines 182 to 187
type_params: (
tuple[typing.TypeVar | typing.ParamSpec | typing.TypeVarTuple, ...]
| frozenset[str]
| None
) = None,
recursive_guard: frozenset[str] | None = None,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
type_params: (
tuple[typing.TypeVar | typing.ParamSpec | typing.TypeVarTuple, ...]
| frozenset[str]
| None
) = None,
recursive_guard: frozenset[str] | None = None,
*args: Any, **kwargs: Any

and then pass those through, much simpler and safer. I don't think this version of ForwardRef needs to be particularly user-friendly or well-hinted, and accurate hints depend on the Python version anyway. @bswck wdyt?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PerchunPak if you're happy with this suggestion then you can go ahead with it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and then pass those through, much simpler and safer. I don't think this version of ForwardRef needs to be particularly user-friendly or well-hinted, and accurate hints depend on the Python version anyway. @bswck wdyt?

Agree

Copy link
Contributor

@bswck bswck Dec 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can @functools.wraps(ForwardRef._evaluate) in case we want to be pedantic.
That... *should*... work.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea, thanks!

Python 3.12 added a new argument which broke the library. It also made
one of the arguments keyword-only which I also fixed.
@alexmojaki alexmojaki merged commit 86d1dda into alexmojaki:main Dec 21, 2024
50 checks passed
@alexmojaki
Copy link
Owner

Thanks @PerchunPak!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ForwardRef is broken on 3.12
3 participants