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
Make @particle_input
compatible with from __future__ import annotations
#2479
Make @particle_input
compatible with from __future__ import annotations
#2479
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2479 +/- ##
==========================================
- Coverage 97.37% 97.37% -0.01%
==========================================
Files 104 104
Lines 9401 9399 -2
==========================================
- Hits 9154 9152 -2
Misses 247 247 ☔ View full report in Codecov by Sentry. |
@@ -9,7 +9,7 @@ | |||
from collections.abc import Callable, Iterable, MutableMapping | |||
from inspect import BoundArguments | |||
from numbers import Integral, Real | |||
from typing import Any, Optional, TypedDict, Union | |||
from typing import Any, Optional, TypedDict, Union, get_type_hints |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ChatGPT suggested using typing.get_type_hints
because other methods returned the string representations of the annotations rather than the actual objects. I don't know how long this would have taken me to figure out otherwise!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ChatGPT 😱
…ut-from-future-annotations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What an annoying little bug 👍
If postponed evaluation of annotations had become the default in a future version of Python before this was fixed, this would have been an annoying little bug that broke the entire package! 🙃 |
@JaydenR2305 — thank you for finding this bug in #2245! It should be fixed once this is merged. |
Description
@JaydenR2305 found a bug that
@particle_input
did not work on an instance method when preceded byfrom __future__ import annotations
, which delays the evaluation of annotations. The purpose of this PR is to fix that bug.However, at the moment I don't actually know how to fix it, so I'm going to start with writing some purposefully failing tests that reproduce the bug, and then try to get it to work somehow.
Wish me luck! 🙃
Related issues
Bug originally observed in #2245.