-
Notifications
You must be signed in to change notification settings - Fork 114
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 imports in a module containing __future__ #387
Conversation
3a3de78
to
27275eb
Compare
Are the test suites passing for you locally? |
cb25bd5
to
7dfb1ef
Compare
Yes, I can get a clean run with |
@agronholm All 💚 now! |
Installing pre-commit locally would have made that easier.. |
The test for this really belongs in |
How do you run it locally? I tried |
It seemed like |
First of all, you should do |
The problem seems to stem from |
I'm likely to reject this PR in favor of an alternate approach and an alternate test. |
Here's a test that fails without any patch: def test_respect_future_import() -> None:
# Regression test for #385
node = parse(
dedent(
'''
from __future__ import annotations
def foo() -> int:
return 1
'''
)
)
TypeguardTransformer().visit(node)
assert (
unparse(node)
== dedent(
'''
from __future__ import annotations
from typeguard import TypeCheckMemo
from typeguard._functions import check_return_type
def foo() -> int:
memo = TypeCheckMemo(globals(), locals())
return check_return_type('foo', 1, int, memo)
'''
).strip()
) |
Fair enough! Let me know if you want me to help. |
Thanks for this! Seems to pass with my changes. Shall I commit it? |
I'm still considering my options. If I figure out a better way, I'll just push that and close this PR. Either way I'll let you know. |
7dfb1ef
to
cc926b8
Compare
Sounds good. I added the test in case we merge this PR. |
cc926b8
to
da99fe3
Compare
Alright, I resolved this via c11057a. Thanks for your initiative on the matter. |
Thanks! Would it be possible to release the latest changes? |
Done. |
Fixes: #385