Skip to content

docs: document SupportsInt conversion behavior for query params#1638

Open
toroleapinc wants to merge 2 commits intoaio-libs:masterfrom
toroleapinc:docs/issue-1458-document-supportsint-conversion
Open

docs: document SupportsInt conversion behavior for query params#1638
toroleapinc wants to merge 2 commits intoaio-libs:masterfrom
toroleapinc:docs/issue-1458-document-supportsint-conversion

Conversation

@toroleapinc
Copy link
Copy Markdown

Summary

Documents the behavior where objects implementing SupportsInt (such as uuid.UUID) are converted to int when used as query parameter values.

Closes #1458

Changes

  • Added a warning box to the with_query documentation explaining the SupportsIntint conversion behavior
  • Included a concrete uuid.UUID example showing the correct usage pattern (explicit str() conversion)
  • Enhanced the query_var() docstring to note this behavior
  • Added towncrier changelog fragment

Context

As discussed in #1458, the maintainers decided that the current behavior (converting SupportsInt objects to int) should be kept, but documented clearly so users know to explicitly convert types like uuid.UUID to strings.

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>
@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label Mar 3, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 3, 2026

Merging this PR will not alter performance

✅ 99 untouched benchmarks


Comparing toroleapinc:docs/issue-1458-document-supportsint-conversion (53d874c) with master (148fc70)

Open in CodSpeed

Comment thread docs/api.rst

.. warning::

Any object implementing :class:`~typing.SupportsInt` (i.e. having an
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread docs/api.rst Outdated
.. warning::

Any object implementing :class:`~typing.SupportsInt` (i.e. having an
``__int__`` method) will be converted to :class:`int` before being used
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method can actually be linked:

Suggested change
``__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
Copy link
Copy Markdown

codecov bot commented Mar 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.47%. Comparing base (dc871b6) to head (53d874c).
⚠️ Report is 3 commits behind head on master.

❌ 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     
Flag Coverage Δ
CI-GHA 99.47% <ø> (+0.10%) ⬆️
MyPy 97.63% <ø> (ø)
OS-Linux 99.70% <ø> (-0.03%) ⬇️
OS-Windows 98.42% <ø> (-0.24%) ⬇️
OS-macOS 98.56% <ø> (-0.24%) ⬇️
Py-3.10.11 98.39% <ø> (-0.24%) ⬇️
Py-3.10.19 99.63% <ø> (-0.03%) ⬇️
Py-3.11.14 99.63% <ø> (-0.03%) ⬇️
Py-3.11.9 98.39% <ø> (-0.24%) ⬇️
Py-3.12.10 98.39% <ø> (-0.24%) ⬇️
Py-3.12.12 99.63% <ø> (-0.03%) ⬇️
Py-3.13.12 99.68% <ø> (-0.03%) ⬇️
Py-3.13.12t 99.68% <ø> (-0.03%) ⬇️
Py-3.14.3 99.68% <ø> (-0.03%) ⬇️
Py-3.14.3t 99.68% <ø> (-0.03%) ⬇️
Py-pypy3.10.16-7.3.19 99.29% <ø> (-0.03%) ⬇️
VM-macos-latest 98.56% <ø> (-0.24%) ⬇️
VM-ubuntu-latest 99.70% <ø> (-0.03%) ⬇️
VM-windows-latest 98.42% <ø> (-0.24%) ⬇️
pytest 99.73% <ø> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided There is a change note present in this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Convert an uuid.UUID variable into int when pass it in params

2 participants