-
-
Notifications
You must be signed in to change notification settings - Fork 107
Update special dataclass handling #153
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
Conversation
The CI failures don't appear to be a regression of this patch. I get these same warnings when running tox against master:
|
The related issue is https://github.com/agronholm/sphinx-autodoc-typehints/issues/123. Let's also be aware that @agronholm is looking for a new maintainer (https://github.com/agronholm/sphinx-autodoc-typehints/issues/146). I would very much like to see this issue fixed. |
Is it possible to get CI to exhibit those errors? And then have this change fix tests which would otherwise fail in CI? https://github.com/agronholm/sphinx-autodoc-typehints/pull/155 includes a fix for the CI issues you were hitting. As a reader, I would expect |
yes. if you run CI on master with a version of python that has these changes (I'm using 3.8.5), it will show The difference is the input type. Thanks for the review! |
My preference (and again, I am not a maintainer or gatekeeper on this project) is to modify
warnings = warning.getvalue().strip()
assert 'Cannot resolve forward reference in type annotations of ' in warnings, warnings
warnings = warning.getvalue().strip().splitlines()
# ... now assert something about each expected warning This should fail (not just warn!) on CI and give a heads up ASAP when things break in future.
A comment detailing exactly what you just said would be great (for me personally as a reader). |
@lbenezriravin would you mind rebasing against current master? The CI failures should be gone. |
I elaborated in the comment to clarify as per @adamtheturtle 's request. While I agree that the proposed update to the tests is probably better, IMO it's out of scope for this specific patch to refactor the unit tests. |
The reason I suggested it is I think that if there is a reported bug and there is no failing test for that bug, then an appropriate scope includes adding (or modifying) a test which would demonstrate that bug, and then fixing that test. |
That said - I would be more than happy to see this merged so I can remove my workaround hacks! |
Sorry for the delay. I see that the unit tests no longer fail when I remove this patch, probably due to the CI fix. You're right, adding a protection is absolutely in scope in that case. I'm a little busy for the next few days, but I'll try to get an update in soon. |
Of note is that it was necessary to add a logger filter to suppress a warning from incorrect code in sphinx_autodoc_typehints. Workaround FROM: https://github.com/agronholm/sphinx-autodoc-typehints/issues/123#issuecomment-698314873 Probable Real Fix: https://github.com/agronholm/sphinx-autodoc-typehints/pull/153
@lbenezriravin If you'd like to share this branch with me I'm happy to add some tests 😄 |
Sorry for the delay. I added a protection for this bug and verified that my patch fixes it. |
One or more tests use f-strings which are not compatible with Python 3.5. As 3.5 is now EOL, I will drop it soon, but until I do that please use 3.5 compatible syntax. |
ah, my bad. I don't have 3.5 installed, so those tests were being skipped when I tested locally. |
The existing test did not have any fields and missed an edge case in a bugfix python version update.
The dataclass generated qualnames were updated in a patch version of python, likely the update that either caused or fixed https://bugs.python.org/issue34776 Fixes tox-dev#123
I'm not really sure how to resolve this -- python 3.5 doesn't support type hinting variables (pep526), which I need in order to catch this bug on later versions of python. Since the tests are a monolith, I'm not seeing a super clean way to skip testing dataclasses on python3.5 (since it doesn't matter there anyways). |
Add this to import re
import sys
version_re = re.compile(r'_py(\d)(\d)\.py$')
def pytest_ignore_collect(path, config):
match = version_re.search(path.basename)
if match:
version = tuple(int(x) for x in match.groups())
if sys.version_info < version:
return True Then name the test module with a |
Since there's only one test module, wouldn't that skip all tests for python 3.5? How is that different from just removing py35 from tox? |
The point is that you put all the tests requiring 3.6+ syntax in a new test module with the |
Alright, I think I broke out the dataclass test as cleanly as possible. Thank you for your help! edit: removed a rogue .swp file |
py35 doesn't have support for the syntax needed to test this feature
Thanks! |
Thank you @agronholm and @lbenezriravin for your hard work on this. @agronholm - Is it possible to have a release with this change soon? Is there anything that I can do to help? |
I'll try to get a release out within the next couple days. |
Thank you @agronholm 🙏 |
v1.11.1 released. |
The existing unit tests appear to catch this regression when running with a python version that exhibits this change, so I didn't add an additional protection.
Please let me know I'm missing anything in this patch. Thanks for a great tool!