-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
surprising new behavior in inspect/annotationlib get_annotations as of 3.14.0b1, not in 3.14.0a7. intended change? #133684
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
Comments
further issues that seem related to the same thing make two files, one with lib.py
then make app.py:
annotations for "foo" are lost in 3.14.0b1
|
also suffice to say this is a way worse issue for SQLAlchemy than the conditionals thing. we have no way to work around this |
I think the workaround is to not use |
That's not a workaround for us, this is the SQLAlchemy library. We use modern annotations so we need |
This change seems to fix your cases:
Unfortunately this issue brings us back to a state where I'll put up a PR with this change later after I've had some time to write tests. Thanks for the early feedback, and sorry I didn't test behavior with the future import enough. |
OK so I can just vendor that code right now to try to workaround? great |
that's ironically pretty much the code we used in python versions prior to 3.10 |
this seems to be working though I am getting better results when I am using the exact version of
otherwise I'm getting errors on some other classes, |
I found another issue with TypedDict, and it seems similar to these, but is different in that the |
that new report is at #133701 |
Changes to the test suite to accommodate Python 3.14 as of version 3.14.0b1 Originally this included a major breaking change to how python 3.14 implemented :pep:`649`, however this was resolved by [1]. As of a7, greenlet is skipped due to issues in a7 and later b1 in [2]. 1. the change to rewrite all conditionals in annotation related tests is reverted. 2. test_memusage needed an explicit set_start_method() call so that it can continue to use plain fork 3. unfortunately at the moment greenlet has to be re-disabled for 3.14. 4. Changes to tox overall, remove pysqlcipher which hasn't worked in years, etc. 5. we need to support upcoming typing-extensions also, install the beta 6. 3.14.0a7 introduces major regressions to our runtime typing utilities, unfortunately, it's not clear if these can be resolved 7. for 3.14.0b1, we have to vendor get_annotations to work around [3] [1] python/cpython#130881 [2] python-greenlet/greenlet#440 [3] python/cpython#133684 py314: yes Fixes: #12405 References: #12399 Change-Id: I8715d02fae599472dd64a2a46ccf8986239ecd99
Changes to the test suite to accommodate Python 3.14 as of version 3.14.0b1 Originally this included a major breaking change to how python 3.14 implemented :pep:`649`, however this was resolved by [1]. As of a7, greenlet is skipped due to issues in a7 and later b1 in [2]. 1. the change to rewrite all conditionals in annotation related tests is reverted. 2. test_memusage needed an explicit set_start_method() call so that it can continue to use plain fork 3. unfortunately at the moment greenlet has to be re-disabled for 3.14. 4. Changes to tox overall, remove pysqlcipher which hasn't worked in years, etc. 5. we need to support upcoming typing-extensions also, install the beta 6. 3.14.0a7 introduces major regressions to our runtime typing utilities, unfortunately, it's not clear if these can be resolved 7. for 3.14.0b1, we have to vendor get_annotations to work around [3] [1] python/cpython#130881 [2] python-greenlet/greenlet#440 [3] python/cpython#133684 py314: yes Fixes: #12405 References: #12399 Change-Id: I8715d02fae599472dd64a2a46ccf8986239ecd99
Thanks, did you figure out anything about the |
I'm not able to get back to that same error and I suspect it had something to do with something internal, however, trying to find it I may have uncovered more problems here |
Yeah we'll need to go back to the |
OK the subsequent problem I'm having has to do with something related but out of the immediate scope here, I'm attempting to runtime set annotations on a class to something other than what they were, for the purposes of getting python's dataclass() function to interpret the class in a certain way, and if that class is in a hierarchy, the assignment of new annotations is not working. Admittedly setting annotations to something new is a little more of a hack, so something broke with that as of 3.14b1, so ill try to figure that out more. |
That sounds like it should still work, if you can minimize the repro case please open a new issue. Thanks for all the testing! |
if you just assign to |
Ugh that seems to be another |
oh OK. I just put it in #133778 as you were typing this |
Bug report
Bug description:
3.14.0b1 seems to be interpreting the annotations of a metaclass into a new format that is also interfering with the correct annotations of subclasses of that class. The subclass reports the annotations of the parent class, if it does not itself have any annotations. this only occurs if superclass is from a custom metaclass. if the subclass does have annotations, then the superclass annotations are not reported. this behavior is inconsistent with previous python versions including 3.14.0a7 and is also inconsistent with itself. see script below
outputs:
CPython versions tested on:
3.14
Operating systems tested on:
No response
Linked PRs
The text was updated successfully, but these errors were encountered: