Skip to content

Conversation

@patchback
Copy link
Contributor

@patchback patchback bot commented Jul 6, 2024

This is a backport of PR #8463 as merged into master (9386854).

What do these changes do?

Improve the request typing by using 3.11's new Unpack operator to properly type the kwargs that live on each HTTP method. Using typing_extensions, this is supported on older versions of Python as well.

To do this, I did add typing-extensions as a requirement on versions of Python before 3.11. I think this trade-off is well worth it, as it drastically improves the static typing checking experience, and the intellisense experience for VSCode users on Pylance. typing-extensions will also let aiohttp use other typing backports without having to wait multiple years until the minimum supported version Python catches up.

Are there changes in behavior for the user?

Users will be improved type-checking when making requests, if improper/unexpected types are being used, they might notice new typing warnings.

Is it a substantial burden for the maintainers to support this?

No, updates to the request arguments simply need to be mirrored with the typed dict added, which will update all of the core HTTP methods.

Related issue number

Fixes #4749

Checklist

  • I think the code is well written
  • Unit tests for the changes exist (not applicable, no logic changes)
  • Documentation reflects the changes (type-checking changes)
  • If you provide code modification, please add yourself to CONTRIBUTORS.txt
    • The format is <Name> <Surname>.
    • Please keep alphabetical order, the file is sorted by names.
  • Add a new news fragment into the CHANGES/ folder
    • name it <issue_or_pr_num>.<type>.rst (e.g. 588.bugfix.rst)

    • if you don't have an issue number, change it to the pull request
      number after creating the PR

      • .bugfix: A bug fix for something the maintainers deemed an
        improper undesired behavior that got corrected to match
        pre-agreed expectations.
      • .feature: A new behavior, public APIs. That sort of stuff.
      • .deprecation: A declaration of future API removals and breaking
        changes in behavior.
      • .breaking: When something public is removed in a breaking way.
        Could be deprecated in an earlier release.
      • .doc: Notable updates to the documentation structure or build
        process.
      • .packaging: Notes for downstreams about unobvious side effects
        and tooling. Changes in the test invocation considerations and
        runtime assumptions.
      • .contrib: Stuff that affects the contributor experience. e.g.
        Running tests, building the docs, setting up the development
        environment.
      • .misc: Changes that are hard to assign to any of the above
        categories.
    • Make sure to use full sentences with correct case and punctuation,
      for example:

      Fixed issue with non-ascii contents in doctest text files
      -- by :user:`contributor-gh-handle`.

      Use the past tense or the present tense a non-imperative mood,
      referring to what's changed compared to the last released version
      of this project.

@codecov
Copy link

codecov bot commented Jul 6, 2024

Codecov Report

Attention: Patch coverage is 80.00000% with 10 lines in your changes missing coverage. Please review.

Please upload report for BASE (3.10@6d2c5cb). Learn more about missing BASE report.

Files with missing lines Patch % Lines
aiohttp/client.py 80.00% 8 Missing and 2 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             3.10    #8484   +/-   ##
=======================================
  Coverage        ?   97.49%           
=======================================
  Files           ?      108           
  Lines           ?    33318           
  Branches        ?     4003           
=======================================
  Hits            ?    32482           
  Misses          ?      610           
  Partials        ?      226           
Flag Coverage Δ
CI-GHA 97.40% <80.00%> (?)
OS-Linux 97.07% <80.00%> (?)
OS-Windows 94.70% <ø> (?)
OS-macOS 96.73% <80.00%> (?)
Py-3.10.11 96.85% <80.00%> (?)
Py-3.10.14 96.81% <80.00%> (?)
Py-3.11.9 97.04% <80.00%> (?)
Py-3.12.4 97.15% <80.00%> (?)
Py-3.8.10 94.44% <ø> (?)
Py-3.8.18 96.70% <80.00%> (?)
Py-3.9.13 96.84% <80.00%> (?)
Py-3.9.19 96.81% <80.00%> (?)
Py-pypy7.3.16 96.37% <80.00%> (?)
VM-macos 96.73% <80.00%> (?)
VM-ubuntu 97.07% <80.00%> (?)
VM-windows 94.70% <ø> (?)

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.

@Dreamsorcerer Dreamsorcerer merged commit 9562eef into 3.10 Jul 6, 2024
@Dreamsorcerer Dreamsorcerer deleted the patchback/backports/3.10/9386854800af026dfa60bcef80615eae1cea94ac/pr-8463 branch July 6, 2024 00:52
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.

3 participants