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 ParamSpec for wrapped signatures #508

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Conversation

Dreamsorcerer
Copy link
Member

@Dreamsorcerer Dreamsorcerer commented Jul 25, 2023

Fixes #504.

There are still a couple of issues with this.

  1. Typing doesn't seem to work correctly with instance methods. Not sure exactly what is going wrong here, needs some more investigation.
  2. partial() use will cause new type errors. We can either wait until partial() is properly supported by typedshed/mypy (functools.partial should use PEP612 ParamSpec (depends on #8708) python/typeshed#8703 / functools.partial support python/mypy#1484), or we could expose a TypeAlias of _LRUCacheWrapper so it can be used in type annotations.
  3. There also seems to be an issue with pypy, possibly a bug in pypy, but needs further investigation.

@codecov
Copy link

codecov bot commented Jul 25, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.92%. Comparing base (f60bf71) to head (0e56d88).
Report is 52 commits behind head on master.

Current head 0e56d88 differs from pull request most recent head c8156f9

Please upload reports for the commit c8156f9 to get more accurate results.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #508      +/-   ##
==========================================
+ Coverage   96.88%   96.92%   +0.03%     
==========================================
  Files          12       12              
  Lines         770      780      +10     
  Branches       91       93       +2     
==========================================
+ Hits          746      756      +10     
  Misses         22       22              
  Partials        2        2              
Flag Coverage Δ
unit 96.53% <91.66%> (-0.22%) ⬇️

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.

Copy link
Member

@asvetlov asvetlov left a comment

Choose a reason for hiding this comment

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

Good step forward, thanks!

files = async_lru, tests
check_untyped_defs = True
follow_imports_for_stubs = True
disallow_any_decorated = True
Copy link
Member

Choose a reason for hiding this comment

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

Do you have a reason for enumerating all mypy options?
I would prefer strict = true plus maybe a few additional fine-tunes.
Maintaining all mypy opts adds a burden; I never could keep all these options in my mind without looking in docs

Copy link
Member Author

Choose a reason for hiding this comment

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

This adds a lot more options than strict. This is the config we started in aiohttp a few years ago. Basically, strict isn't so strict, so we like to enable all the options that aren't too much.

At some point I'd like to find a way to make a config that's reusable across all projects without copy/paste, which will ease the maintenance burden.

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.

Signature of decorated function is not type checked by mypy
2 participants