Commit Graph

51 Commits

Author SHA1 Message Date
Shantanu
470a13ab09 Use PEP 570 syntax in stdlib (#11250) 2024-03-09 14:50:16 -08:00
Nikita Sobolev
863d22a239 Make return type of functools.cache_property covariant (#10053)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-02-17 15:38:46 -08:00
Sebastian Rittau
53a8193d64 Update typing_extensions imports in stdlib (#11244)
Co-authored-by: AlexWaygood <alex.waygood@gmail.com>
2024-01-05 08:15:19 -08:00
Sebastian Rittau
23604858a6 Remove Python 3.7 branches (#11238) 2024-01-05 11:39:39 +01:00
Rayan Sóstenes
9fbf2e1c0c Fix: functools.reduce does not accept keyword arguments (#11090) 2023-11-30 13:44:52 +00:00
Rebecca Chen
f0a79939ae Fix typo in functools.pyi: _RWapper -> _RWrapper. (#10705) 2023-09-12 19:55:01 +01:00
Nikita Sobolev
e347af1d59 Update functools.pyi for Python3.12 (#10269) 2023-06-06 22:48:36 +01:00
Nikita Sobolev
1d9f35369d functools: Add cache_parameters method to _lru_cache_wrapper (#10076)
The docs says that `cache_parameters()` function was added in 3.9: https://docs.python.org/3/library/functools.html#functools.lru_cache
Source: af53046995/Lib/functools.py (L512)
But, `typeshed` does not have it.
2023-04-24 07:29:54 -07:00
Nikita Sobolev
972958a406 functools.cached_property.__get__ returns Self (#9992)
Source code: 21e9de3bf0/Lib/functools.py (L979-L980)
2023-03-30 17:37:15 +01:00
Alex Waygood
dd2818a41d Stdlib: add container default values (#9909) 2023-03-21 09:12:34 +01:00
Thomas M Kehrenberg
d76259a062 Add __name__ to _Wrapped in functools (#9835) 2023-03-03 15:02:51 +00:00
Eric Traut
9c4bfd5d11 Updated functools.wraps and functools.update_wrapper (#6670)
Updated functools.wraps and functools.update_wrapper to use ParamSpec to preserve signatures of wrapped and wrapper functions.
2023-02-26 12:41:08 +01:00
Thomas M Kehrenberg
40d853cbe2 Add __set__ to functools.cached_property (#9762) 2023-02-20 12:36:45 +00:00
Andrew Svetlov
39fcd396ce lru_cache.cache_info().maxsize can be None for infinite cache size (#9763) 2023-02-19 16:50:19 +00:00
Alex Waygood
9ed39d8796 Use typing_extensions.Self in the stdlib (#9694) 2023-02-09 09:12:13 +00:00
Alex Waygood
53747b264e Stdlib: add 'obvious' default values (#9688) 2023-02-07 13:00:40 +01:00
Alex Waygood
8e7b78a8e8 Bump black to 23.1.0 (#9647) 2023-02-01 06:06:04 -08:00
Alex Waygood
33a62ae42d Add more defaults to the stdlib (#9606)
Continuing work towards #8988.

The first five commits were created using stubdefaulter on various Python versions; the following commits were all created manually by me to fix various problems. The main things this adds that weren't present in #9501 are:

- Defaults in Windows-only modules and Windows-only branches (because I'm running a Windows machine)
- Defaults in non-py311 branches
- Defaults for float parameters
- Defaults for overloads
2023-01-29 01:51:23 +00:00
Jelle Zijlstra
ddfaca3200 stdlib: add argument default values (#9501) 2023-01-18 09:37:34 +01:00
Alex Waygood
e2ce7c6344 stdlib: audit more callback annotations (#8209) 2022-07-19 07:07:25 -07:00
Alex Waygood
1be5918baa Use _typeshed.IdentityFunction more consistently (#8063) 2022-06-12 16:56:14 -07:00
Alex Waygood
e88a182573 Simplify __all__ definitions in modules beginning with 'a' to 'l' (#8026) 2022-06-07 15:40:48 +02:00
Alex Waygood
b093c90a94 Use TypeAlias for type aliases where possible, part II (#7667) 2022-04-20 20:02:47 +01:00
Alex Waygood
97a74bc1aa Import from collections.abc wherever possible (#7635) 2022-04-18 12:50:37 +02:00
Alex Waygood
740193a8fc Use TypeAlias where possible for type aliases (#7630) 2022-04-15 18:01:00 -07:00
Alex Waygood
bc72b25a2a Make more miscellaneous fields read-only, annotate _json.make_encoder (#7439) 2022-03-06 15:41:49 -08:00
Alex Waygood
2fe519c3a7 Add __all__ for modules beginning with 'e', 'f' and 'g' (#7325) 2022-02-20 15:08:14 -08:00
Alex Waygood
1091521f60 stdlib: Add several missing __(deep)copy__ methods (#7242) 2022-02-16 18:57:41 -08:00
Alex Waygood
96b06adf2c Add missing descriptor methods in dataclasses and functools (#7203) 2022-02-15 06:45:49 -08:00
Alex Waygood
dea12b2c47 Add missing __isabstractmethods__ attributes in abc and `functools1 (#7205) 2022-02-14 11:20:07 -08:00
Shantanu
b88a6f19cd Upgrade black version (#7089) 2022-01-30 16:27:06 -08:00
Nikita Sobolev
f5db1ccbbd Use tuple of Literal types in functools.pyi (#6915) 2022-01-21 20:51:52 -08:00
Alex Waygood
96c9abb058 Always use _typeshed.Self, where applicable (#6880)
* Always use `_typeshed.Self`, where applicable

* Revert changes to `google-cloud-ndb` (ambiguous)

* Remove empty line added by script

* Revert changes to `stubs/python-dateutil/dateutil/relativedelta.pyi`

* Manually add a few more that the script missed

* Improve `filelock` annotation

Source code here: 79ec7b2826/src/filelock/_api.py (L207)

* Improve `opentracing/scope` annotation

Source code here: 3e1d357a34/opentracing/scope.py (L71)

* Improve `redis/client` stub

Source code here: 15f315a496/redis/client.py (L1217)

* Improve `redis/lock` annotation

Source code here: 15f315a496/redis/lock.py (L155)

* Improve `requests/models` annotation

Source code here: d718e75383/requests/models.py (L653)
2022-01-09 19:16:19 -08:00
Alex Waygood
a40d79a4e6 Use lowercase type everywhere (#6853) 2022-01-08 16:09:29 +01:00
Neil Girdhar
1b3d629bc5 Make self positional-only in functools.partial and partialmethod (#6822) 2022-01-07 19:19:13 +02:00
Neil Girdhar
9116b2928d functools: Add partial.__new__; remove partial.__init__ (#6813) 2022-01-04 23:48:34 +02:00
Alex Waygood
8d5d2520ac Use PEP 585 syntax wherever possible (#6717) 2021-12-28 11:31:43 +01:00
Alex Waygood
5670ca2f75 Add SupportsRichComparison type to _typeshed (#6583)
Use it to improve types of `max()` and other functions.

Also make some other tweaks to types related to comparison dunders.

Fixes #6575
2021-12-14 14:12:23 +00:00
Jukka Lehtosalo
a7798f6060 Revert "lru_cache preserves signature of wrapped function (#6221)" (#6356)
This reverts commit 8bda66a737.

The change causes issues with ParamSpec implementations in type
checkers, at least pyright and my work-in-progress support for
ParamSpec in mypy. It's not yet clear how to fix the issues, so I
think that it's best to revert this, at least temporarily until we've
found a good solution. See #6347 for context.
2021-11-22 12:52:27 +01:00
Alex Waygood
5c8e68f0eb Use lowercase set, frozenset and deque where possible (#6346) 2021-11-19 15:05:45 -08:00
Alex Waygood
10c9d8cfce Add @final to many unsubclassable stdlib classes (#6299) 2021-11-15 14:45:24 +01:00
Tomaz-Vieira
8bda66a737 lru_cache preserves signature of wrapped function (#6221)
Update pytype for a fix to ParamSpec as argument to Generic
2021-11-03 10:08:52 +01:00
Bas van Beek
b9e1d7d522 Replace Mapping with types.MappingProxyType (#6013)
Mark `Signature.parameters` and `.return_annotation` as read-only properties
2021-09-09 09:58:53 +02:00
Akuli
ce11072dbe Big diff: use lower-case list and dict (#5888) 2021-08-08 09:26:35 -07:00
Akuli
ee487304d7 Big diff: Use new "|" union syntax (#5872) 2021-08-08 11:05:21 +02:00
Akuli
933787d5fe return Hashable from functools._make_key (#5385) 2021-05-09 20:23:40 +03:00
Mahmoud Harmouch
0804505c10 Add functools._make_key (#5370)
* Add functools._make_key

* Added _HashedSeq class
2021-05-08 23:40:33 +03:00
Sebastian Rittau
45916045c8 Upgrade black to 21.4b0 and reformat (#5250)
This introduces newlines before decorators.
2021-04-26 13:58:27 +02:00
Eric Traut
e2967a8bee Eliminated the use of "bare" TypeVars in stdlib stubs (#5041)
Eliminated the use of "bare" TypeVars (i.e. a TypeVar that appears only once) within generic methods. While not considered an error in PEP 484, these are a common source of bugs in code, and some type checkers (including pytype and pyright) flag them as errors.

Co-authored-by: Eric Traut <erictr@microsoft.com>
2021-02-27 19:43:45 -08:00
Eric Traut
18a229da97 functools: add type argument to Type annotation (#4977)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2021-01-27 20:03:20 -08:00