First pass at using typing.ParamSpec to tighten types for callables.
I found some of these changes to be useful.
The following minimal example raises no errors today but gives Argument of type "Literal['val']" cannot be assigned to parameter "val" of type "int" "Literal['val']" is incompatible with "int" [Pyright: reportGeneralTypeIssues] on da0d7a7a36cb449db74be9c58a42d441d8bca350 .
import asyncstdlib as a
@a.sync
def sync_inc(val: int) -> int:
return val + 1
async def bad() -> int:
return await sync_inc("val")
This pull request introduces 1 alert when merging da0d7a7a36cb449db74be9c58a42d441d8bca350 into da9c603144e0380097fe31c0f84314a3869f6170 - view on LGTM.com
new alerts:
- 1 for Unused import
Codecov Report
Merging #90 (6921b35) into master (da9c603) will increase coverage by
0.00%. The diff coverage is100.00%.
@@ Coverage Diff @@
## master #90 +/- ##
=======================================
Coverage 99.25% 99.25%
=======================================
Files 20 20
Lines 2005 2010 +5
Branches 307 308 +1
=======================================
+ Hits 1990 1995 +5
Misses 10 10
Partials 5 5
| Impacted Files | Coverage Δ | |
|---|---|---|
| asyncstdlib/itertools.py | 99.04% <ø> (ø) |
|
| asyncstdlib/_core.py | 100.00% <100.00%> (ø) |
|
| asyncstdlib/_typing.py | 100.00% <100.00%> (ø) |
|
| asyncstdlib/asynctools.py | 100.00% <100.00%> (ø) |
|
| asyncstdlib/builtins.py | 98.67% <100.00%> (ø) |
|
| asyncstdlib/contextlib.py | 100.00% <100.00%> (ø) |
|
| asyncstdlib/heapq.py | 98.82% <100.00%> (ø) |
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
Thanks for this PR! It might take a bit until we have MyPy and Pyright agree but this is very welcome.
Thanks for the suggestions. I went on vacation and completely forgot about this. Ill push up changes this weekend :)
Hi @varoonp123, it looks like you are having trouble finishing this PR. Since I agree with you that this is really useful, I would like to finish the PR myself. Do you have any objections to this?
Note that you will retain authorship of any commits you have pushed so far and will still be listed as author of the PR.