-
Notifications
You must be signed in to change notification settings - Fork 517
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
Prefer python_multipart import over multipart #3710
Prefer python_multipart import over multipart #3710
Conversation
This avoids a |
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.
Thanks for the contribution! This mostly looks good.
Two things though:
- Would you be able to add a test to ensure we don't get the
PendingDeprecationWarning
? - Also small nit, I think it might be better to
import python_multipart as multipart
. This would minimize the diff, since we would not need to update existing usages ofmultipart
.
Let me know what you think; I can also take over the PR from here if you prefer.
sentry_sdk/integrations/starlette.py
Outdated
# python-multipart 0.0.13 and later | ||
import python_multipart # type: ignore | ||
except ImportError: | ||
# python-multipart 0.0.12 and later |
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.
Did you mean "earlier" here?
# python-multipart 0.0.12 and later | |
# python-multipart 0.0.12 and earlier |
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.
Good catch. Thanks. I will fix this.
Codecov ReportAll modified and coverable lines are covered by tests ✅
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## master #3710 +/- ##
==========================================
- Coverage 84.28% 84.27% -0.02%
==========================================
Files 133 133
Lines 14257 14260 +3
Branches 2405 2405
==========================================
+ Hits 12017 12018 +1
+ Misses 1490 1489 -1
- Partials 750 753 +3
|
I am not sure how to add a proper test since the sentry-python/tests/integrations/starlette/test_starlette.py Lines 16 to 19 in d48dc46
And of course, a second import would use caches, and the warning would not be triggered again. Maybe I can wrap the import with
Sure, that’s fine. I defaulted to using the new import name throughout because I thought it would be least confusing in the future when everyone has forgotten the old name, but there is no harm in doing it as you suggested. I’m going to go ahead and force-push with the other changes while I think about testing. |
a923bf8
to
55ef83c
Compare
…tarlette integrations
See: Kludex/python-multipart#16 See also releases 0.0.13 through 0.0.16 at https://github.com/Kludex/python-multipart/releases.
Added a commit that causes an error to occur in the tests when there is a With just the first commit,
With both commits:
|
55ef83c
to
56550e2
Compare
@musicinmybrain I don't think we should test in this way, with the no warnings assertion outside of a test function. If it is non-trivial to add a test, let's just skip adding a test here. |
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.
Removed the test code, looks good now! Thanks again for the contribution.
See: Kludex/python-multipart#16
See also releases 0.0.13 through 0.0.16 at
https://github.com/Kludex/python-multipart/releases.
This prefers the new
python_multipart
import name for https://pypi.org/project/python-multipart/ introduced in release 0.0.13 to resolve conflicts with https://pypi.org/project/multipart/. A fallback to the originalmultipart
import name remains for compatibility with older versions.Starlette itself now does something similar:
encode/starlette@0.41.0...0.41.2
I tried
tox -e linters
,tox -e py3.13-starlette-latest
,tox -e py3.13-starlette-0.36
, andtox -e py3.13-starlette-0.32
locally. I don’t expect any trouble with the rest of the test matrix.