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

Use globals of original(wrapped) function #97

Merged
merged 5 commits into from
Jun 5, 2024

Conversation

ahnjaeshin
Copy link
Contributor

Fixes: airtai/faststream#1492

The original issue happens because the function is wrapped with a decorator, and type annotation resolution is done in the the decorator's globals. The fix uses func.__module__ instead of func.__globals__

This is because wraps copies the __module__ of the wrapped function, but not the __globals__

@Lancetnik
Copy link
Owner

Thank you a lot for the PR! I'll take a look, what we can do with old versions this evening

@Lancetnik
Copy link
Owner

Also, it will be really glad, if you add a test for your case, that fails for current impl and passes with your changes

@ahnjaeshin
Copy link
Contributor Author

Also, it will be really glad, if you add a test for your case, that fails for current impl and passes with your changes

could you briefly share where i should implement the test? can i make a tests/import_test folder and write the test there?

@ahnjaeshin
Copy link
Contributor Author

Also, it will be really glad, if you add a test for your case, that fails for current impl and passes with your changes

I'll add the test somewhere and fix the code so it runs in 3.8 and 3.9 also.

@Lancetnik
Copy link
Owner

could you briefly share where i should implement the test? can i make a tests/import_test folder and write the test there?

You can just add a test to "tests/test_locals.py" case

@ahnjaeshin
Copy link
Contributor Author

could you briefly share where i should implement the test? can i make a tests/import_test folder and write the test there?

You can just add a test to "tests/test_locals.py" case

I've added the test in tests/test_prebuild.py. Also added another tests/wrapper.py because the require a wrapper function that exists in different module.

@ahnjaeshin
Copy link
Contributor Author

I've addressed your comment, and this time hopefully it will pass all the tests

@Lancetnik
Copy link
Owner

Yeah, thank you a lot for the fix!

@Lancetnik Lancetnik merged commit 5585390 into Lancetnik:main Jun 5, 2024
14 checks passed
@ahnjaeshin ahnjaeshin deleted the fix-globalns branch June 5, 2024 22:39
@ahnjaeshin
Copy link
Contributor Author

Would it be possible to release another version by the weekend?

@Lancetnik
Copy link
Owner

Would it be possible to release another version by the weekend?

I tried to release it yesterday already, but there are some troubles with dirty-equals and python3.8 tests. I have to fixed it before we can make a release

@Lancetnik
Copy link
Owner

@yuyupopo the job is done - you can update FastDepends to 2.4.4 - all should works fine

@ahnjaeshin
Copy link
Contributor Author

@yuyupopo the job is done - you can update FastDepends to 2.4.4 - all should works fine

Thanks a lot!

@Lancetnik
Copy link
Owner

@yuyupopo the job is done - you can update FastDepends to 2.4.4 - all should works fine

Thanks a lot!

Thank your for the PR!

Lancetnik added a commit that referenced this pull request Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Pydantic Model is not fully defined. Possible bug in type resolver
2 participants