docs: document SupportsInt conversion behavior for query params#1638
docs: document SupportsInt conversion behavior for query params#1638toroleapinc wants to merge 2 commits intoaio-libs:masterfrom
Conversation
Document that objects implementing SupportsInt (such as uuid.UUID) are converted to int when used as query parameter values. This can lead to unexpected results, e.g. a UUID being represented as a large integer rather than its standard string form. Added a warning to the with_query documentation with a concrete uuid.UUID example showing the correct usage pattern. Closes aio-libs#1458 Signed-off-by: edvatar <88481784+toroleapinc@users.noreply.github.com>
|
|
||
| .. warning:: | ||
|
|
||
| Any object implementing :class:`~typing.SupportsInt` (i.e. having an |
There was a problem hiding this comment.
FWIW, this protocol has been a part of the data model long before typing was a thing: https://docs.python.org/2.0/ref/numeric-types.html. It's rather a part of the data model that is also additionally represented in typing, not vice versa.
| .. warning:: | ||
|
|
||
| Any object implementing :class:`~typing.SupportsInt` (i.e. having an | ||
| ``__int__`` method) will be converted to :class:`int` before being used |
There was a problem hiding this comment.
This method can actually be linked:
| ``__int__`` method) will be converted to :class:`int` before being used | |
| :external+python:meth:`~object.__int__` method) will be converted to :class:`int` before being used |
Codecov Report✅ All modified and coverable lines are covered by tests. ❌ Your project check has failed because the head coverage (97.63%) is below the target coverage (100.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## master #1638 +/- ##
==========================================
+ Coverage 99.37% 99.47% +0.10%
==========================================
Files 30 30
Lines 5940 5942 +2
Branches 282 283 +1
==========================================
+ Hits 5903 5911 +8
Misses 22 22
+ Partials 15 9 -6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
Documents the behavior where objects implementing
SupportsInt(such asuuid.UUID) are converted tointwhen used as query parameter values.Closes #1458
Changes
with_querydocumentation explaining theSupportsInt→intconversion behavioruuid.UUIDexample showing the correct usage pattern (explicitstr()conversion)query_var()docstring to note this behaviorContext
As discussed in #1458, the maintainers decided that the current behavior (converting
SupportsIntobjects toint) should be kept, but documented clearly so users know to explicitly convert types likeuuid.UUIDto strings.