Commit Graph

68 Commits

Author SHA1 Message Date
Thanos 15f6b0ac15 [contextlib] Deprecate @(async)contextmanager wrapping a function returning Iterator (#12087) 2026-01-23 12:06:18 +01:00
Doug Hoskisson c72a3e97a3 Don't require IO for redirect_stdout (#14905) 2025-10-30 21:43:29 +01:00
Jelle Zijlstra f32d9f08bd stdlib: add __slots__ (#14611) 2025-08-21 07:24:59 -07:00
Brian Schubert f88a09d479 Add @type_check_only to various typeshed-only procotols in stdlib (#14465)
Mark various typeshed-only protocols as `@type_check_only` in stdlib
2025-07-26 20:02:17 +01:00
Janek Nouvertné 8a6bfb0698 Make AsyncExitStack generic on __aexit__ (#13888) 2025-04-27 11:23:34 +03:00
Sebastian Rittau 30b16c168d Drop Python 3.8 branches (#13776) 2025-04-03 10:35:36 +02:00
Avasam 6d6e858e63 Enable Ruff PLC (Pylint Convention) (#13306) 2025-03-03 15:39:40 +01:00
Alyssa Coghlan 3f41b30535 Revert "Improve [Async]ContextDecorator type hinting (#13416)" (#13436)
This reverts commit 57d7c4334b.

The attempted fix loses all type overload information during type
inferencing, so postpone fixing the issue until we have a solution
which doesn't impose such a dramatic loss in functionality.

Reopens #13403
2025-02-13 20:49:51 -08:00
Alyssa Coghlan 57d7c4334b Improve [Async]ContextDecorator type hinting (#13416)
Updated annotations allow access to `__wrapped__` on
decorated callables without complaints from typecheckers.
2025-01-20 17:58:52 +01:00
Stephen Morton 43f637b5e2 add _GeneratorContextManagerBase.__init__ (#13246)
I think that #6676 showed that Paramspec didn't work, but that
wasn't actually the fault of _GeneratorContextManagerBase.
2024-12-27 20:04:57 -08:00
Stephen Morton f554f54673 The four protocol-like ABCs outside of collections.abc inherit from ABC directly (#13005) 2024-11-16 19:00:39 +01:00
Stephen Morton d5fff13c9b add contextlib._GeneratorContextManagerBase (#12885)
Actually putting methods on it may be currently infeasible, but
I don't see why it shouldn't exist at all.
2024-10-23 07:11:06 -07:00
Stephen Morton dbd0d35217 add contextlib._BaseExitStack (#12750)
Improves the MRO of ExitStack and AsyncExitStack

related to https://github.com/python/typeshed/issues/3968
2024-10-06 19:08:27 -07:00
Max Muoto b406ba9315 Add _recreate_cm to ContextDecorator and AsyncContextDecorator (#12479) 2024-08-10 16:00:52 -07:00
Alex Waygood d0f2be92ab Bump pyright to v1.1.360 (#11810) 2024-04-24 14:09:16 +02:00
David Salvisberg f274c78fe5 Make ExitStack, AbstractContextManager and AsyncAbstractContextManager generic in return type of __exit__ (#11048) 2024-04-22 16:43:08 +02:00
Shantanu 470a13ab09 Use PEP 570 syntax in stdlib (#11250) 2024-03-09 14:50:16 -08:00
Alex Waygood c49c84f319 A new shade of Black (#11362) 2024-02-04 16:38:55 -08:00
Alex Waygood 8023ba764a Remove redundant inheritances from Generic and various typing protocols (#10981) 2023-11-06 14:00:25 +01:00
Alex Waygood a08d4c8d2e Remove many redundant inheritances from Generic[] (#10933) 2023-10-26 20:07:20 +02:00
Alex Waygood 257e287fec Stdlib: correct many parameter names (#9815) 2023-03-04 09:53:12 +00:00
Alex Waygood 9ed39d8796 Use typing_extensions.Self in the stdlib (#9694) 2023-02-09 09:12:13 +00: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
Avasam c70d303985 Audit stdlib object annotations (#9519) 2023-01-17 15:40:00 +00:00
Avasam aad1a14890 Use the FileDescriptorOrPath alias consistently in the stdlib (#9513) 2023-01-12 18:14:48 +00:00
Nikita Sobolev 380022c650 Remove empty __init__ methods (#8816) 2022-09-30 13:08:41 +01:00
Ganden Schaffner 9469c1c7ea Make AsyncExitStack.push_async_exit support __aexit__s returning Awaitable[None] (#8596)
Make push_async_exit support __aexit__'s returning Awaitable[None]
2022-08-23 14:28:37 +01:00
Nikita Sobolev 4e5d9d1cca Add missing metaclasses in ast and contextlib (#8497) 2022-08-08 16:08:07 +01:00
Alex Waygood ea7bbbdad7 Move Match and Pattern to re.pyi; move ContextManager protocols to contextlib.pyi (#8447) 2022-07-31 15:27:47 +02:00
Alex Waygood edc0ecd857 Remove Python 3.6 branches from typeshed (#8269) 2022-07-11 10:55:17 +02:00
Alex Waygood e88a182573 Simplify __all__ definitions in modules beginning with 'a' to 'l' (#8026) 2022-06-07 15:40:48 +02:00
Jelle Zijlstra c35ec8ba89 contextlib: Remove explicit base class from ExitStack (#7963)
Fixes #7961
2022-05-27 09:19:18 -07:00
Jelle Zijlstra d77d848975 contextlib: Use bound TypeVar (#7764) 2022-05-02 08:57:21 +02: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 da3e69d093 stdlib: Improve a bunch of __(a)exit__ methods (#7571) 2022-04-01 08:05:25 +02:00
Alex Waygood a3245db63c Remove unneeded # noqa comments, fix broken # noqa comments (#7561) 2022-03-28 23:17:44 +02:00
Alex Waygood 5c44ae4f8c Improve various signatures that shouldn't be async def, but currently are (#7491)
Co-authored-by: Thomas Grainger <tagrain@gmail.com>
2022-03-18 20:54:39 -07:00
Alex Waygood 3ab250eec8 Use PEP 604 syntax wherever possible (#7493) 2022-03-16 16:01:33 +01:00
Alex Waygood 947724a5cb stdlib: Add several missing @abstractmethod decorators (#7443) 2022-03-06 16:41:13 -08:00
Alex Waygood 49aa342c15 Add contextlib.__all__ (#7301) 2022-02-19 13:02:34 -08:00
Alex Waygood fbc279e3f5 stdlib: Add many missing dunder overrides (#7231) 2022-02-16 06:25:47 -08:00
Alex Waygood 584336a41e Fix several methods that should be async def, but aren't (#7107) 2022-02-02 15:18:14 +01:00
Jelle Zijlstra 2b72dea679 Allow ExitStack.push callbacks to return None (#7090) 2022-01-31 08:21:32 +01:00
Shantanu b88a6f19cd Upgrade black version (#7089) 2022-01-30 16:27:06 -08:00
Nikita Sobolev 2244bdfa15 Use ParamSpec in contextlib (#7007) 2022-01-23 13:22:05 -08:00
Alex Waygood fe6233a8c3 Add Y027 to list of ignored .flake8 error codes (#6962)
Refs https://github.com/PyCQA/flake8-pyi/pull/104
2022-01-19 07:17:30 -08:00
Alex Waygood 8af5e0d340 Use PEP 585 syntax in Python 2, protobuf & _ast stubs, where possible (#6949) 2022-01-18 07:14:03 -08:00
Alex Waygood a40d79a4e6 Use lowercase type everywhere (#6853) 2022-01-08 16:09:29 +01:00
Alex Waygood 0e75580381 Add missing attributes to contextlib._(Async)GeneratorContextManager (#6676) 2021-12-26 14:05:49 +01:00