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

Add Py version check for using eval_str flag of the inspect.signature() #5083

Merged
merged 3 commits into from
Feb 5, 2024

Conversation

jmao-denver
Copy link
Contributor

Fixes #5075

""" Parse a specific type (top level or nested in a top-level Union annotation) without handling nested types
(e.g. a nested Union). The result is stored in the given _ParsedAnnotation object.
"""
t = eval(t) if isinstance(t, str) else t
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason the eval can't go in the "old" code block of _parse_signature below instead of the logic being split across two files?

Does this line deserve a comment if it stays here?

Copy link
Contributor Author

@jmao-denver jmao-denver Jan 30, 2024

Choose a reason for hiding this comment

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

"eval' the specific type hints here makes sense because this is where they are parsed. _parse_signature handles the whole signature, it would be quite cluttering to dive into individual typing there.

Comment on lines +237 to +240
if sys.version_info.major == 3 and sys.version_info.minor >= 10:
sig = inspect.signature(fn, eval_str=True)
else:
sig = inspect.signature(fn)
Copy link
Member

Choose a reason for hiding this comment

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

Does __future__ provide a way to port this in a cleaner way?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really. I think having an explicit version check actually helps future code cleanup when we bump the minimum supported Python version.

@mofojed
Copy link
Member

mofojed commented Feb 5, 2024

@chipkent / @jmao-denver can this PR get some attention/merged please? This is holding up some merges on our deephaven-plugins side, as it's causing our tests to break: deephaven/deephaven-plugins#217

@jmao-denver jmao-denver enabled auto-merge (squash) February 5, 2024 17:12
@jmao-denver jmao-denver merged commit 01aa467 into deephaven:main Feb 5, 2024
19 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Feb 5, 2024
@jmao-denver jmao-denver deleted the 5075-py38-no-eval_str branch March 4, 2024 18:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Newly added eval_str causes failing update_view in Python versions before 3.10
4 participants