Commit Graph

52 Commits

Author SHA1 Message Date
Brian Schubert 622df68c1c Add @type_check_only to stub-only private classes in stdlib (#14512) 2025-08-03 10:13:16 +02:00
Hunter Hogan 1880490289 Change ast.MatchSingleton.value from Literal[True, False] to bool (#14400)
This is the only annotation in typeshed that uses `Literal[True, False]`. The most similar annotations are `Literal[True, 1]`. 371 annotations are `bool | None`.
2025-07-11 15:55:46 -07:00
Sebastian Rittau d5af6bee35 Clean up deprecated ast.Constant aliases (#14397)
Add `__new__`, remove fields, mark deprecated `Constant` fields as such.
2025-07-11 14:59:53 +02:00
Hunter Hogan 4c3560d3a9 add ast.Num.n as alias for ast.Num.value for backwards compatibility. (#14355) 2025-07-07 13:08:48 +02:00
Hunter Hogan 2f198bcfee Fix return type annotations for ast.parse (#14369) 2025-07-04 15:34:22 -07:00
Brian Schubert d3cfe67377 Fix type of format_spec attribute of ast.Interpolation (#14331) 2025-06-23 19:59:03 -07:00
Hunter Hogan d0f9f40e32 ast: Remove 3 TypeAlias. Fix identifier collision. (#14319) 2025-06-22 06:42:03 -07:00
Hunter Hogan ca543bf390 Add default value to ast.MatchStar.name (#14298) 2025-06-17 21:03:16 -07:00
Jelle Zijlstra c7e29eccd9 ast: Precise type for ast.Constant.value (#14159) 2025-05-27 09:59:02 +02:00
Hunter Hogan cb37f1d7fb Update ast.alias _attributes for Python 3.9 (#14103) 2025-05-19 18:44:10 -07:00
sobolevn 209383988d Add new ast node from 3.14 (#14034) 2025-05-13 08:12:57 -07:00
Semyon Moroz 725f7177b1 Update ast.main function for Python 3.14 (#13982) 2025-05-10 21:32:20 +02:00
Sebastian Rittau 2d50d6b316 Support Python 3.14 (#13957) 2025-05-10 06:27:40 -07:00
Sebastian Rittau 2d46095e3f Fix errors when type checking stdlib with Python 3.14 (#13977) 2025-05-09 21:04:35 +02:00
Hunter Hogan cd98102c6c remove _Identifier: typing_extensions.TypeAlias = str (#13954) (#13964) 2025-05-08 20:40:29 -07:00
Sebastian Rittau dfea9a6a26 Document visit method return type (#13831) 2025-04-15 18:09:33 +02:00
Joren Hammudoglu b266f3e746 Drop Python 3.8 support in ast (#13766) 2025-04-02 08:47:13 +02:00
Stephen Morton 897b350729 fix deprecated ast classes (#13285) 2024-12-27 20:01:53 -08:00
Alex Waygood 9ed47fa8ec Fix linting issues (#12898)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-10-24 14:26:37 +01:00
Christoph Tyralla 8d02c2a6df Use @deprecated for those visit methods of class NodeVisitor that deal with classes that have already been marked with @deprecated and add type: ignore[deprecated] comments. (#12864) 2024-10-21 13:44:57 +02:00
Stephen Morton 77510ae6a4 resort _ast and ast modules (#11162)
The classes imported from the _ast module are defined in C,
but set their __module__ to ast. This arrangement ensures that
the type stubs have the same.

related to https://github.com/python/typeshed/issues/3968
and the discussion in https://github.com/python/typeshed/issues/11141
2024-10-04 17:33:45 -07:00
Max Muoto 815d8bfb7b ast removals for 3.14 (#12488) 2024-08-10 23:51:19 +03:00
Kirill Podoprigora 1794cfd26e [3.14] Add annotations for `ast.compare` (#12111)
Add annotations for ast.compare
2024-06-07 10:21:54 -06:00
Nikita Sobolev 16dadc8fb5 Add show_empty to ast.dump (#11871) 2024-05-07 12:42:16 +02:00
Kirill Podoprigora 74486c31a2 [3.13] Add optimize to ast.parse parameters (#11870) 2024-05-07 11:23:24 +02: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
Jelle Zijlstra 17f8a82376 ast: mark ast.Num etc. as deprecated (#10994) 2023-11-08 19:40:22 +01:00
bzoracler 8d0bdfe9ea add missing method stub for match_case node (#10783)
`match_case` is a leaf node and is a valid target for `visit_*`. See https://github.com/python/cpython/blob/2ef2fffe3be953b91852585c75188d5475b09474/Lib/ast.py#L1697-L1704
2023-09-26 13:27:11 -07:00
Alex Waygood 5b8193b9fd ast.NodeVisitor: add the visit_foo methods for PEP-695 (#10759) 2023-09-24 16:10:16 -07:00
plokmijnuhby b1d4f29ed4 Add definition for visit_MatchSingleton to ast.NodeVisitor (#10758) 2023-09-24 16:26:17 +01:00
Jelle Zijlstra 628c88d995 Update ast for 3.12 (#10201) 2023-06-02 17:11:13 -07: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
Avasam c70d303985 Audit stdlib object annotations (#9519) 2023-01-17 15:40:00 +00:00
Alex Waygood 27983aa929 ast.NodeVisitor: add visit_TryStar on 3.11+ (#9418) 2022-12-27 18:36:53 +01:00
Alex Waygood 154452ffc2 ast.NodeVisitor: Add visit_* methods for ast nodes new in 3.8-3.10 (#9413) 2022-12-26 20:27:44 -08:00
Nikita Sobolev 0e4c59a076 ast.get_docstring does not work with arbitrary AST nodes (#9407) 2022-12-24 18:43:44 +00:00
kasium f9cd5ee859 Improve ast types; revert several "redundant numeric union" changes from #7906 (#9130)
* Adapt number types in ast

Since mypy  0.990 type promotions was limited.
This means that complex is not longer promoted to int/float, therefore
we should adapt the types to list all possible types

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: AlexWaygood <alex.waygood@gmail.com>
2022-11-14 09:41:23 +00:00
Shantanu 093c58bfa2 ast: parse accepts PathLike filename (#9020) 2022-10-28 11:18:38 -07:00
Jelle Zijlstra 5bcd4c1a93 ast: parse takes a ReadableBuffer (#9002)
parse() is basically just a wrapper around compile(), which we
already have as taking ReadableBuffer.
2022-10-27 13:28:02 -07:00
Nikita Sobolev 4e5d9d1cca Add missing metaclasses in ast and contextlib (#8497) 2022-08-08 16:08:07 +01:00
Jelle Zijlstra 250f3d92e7 ast: fix stubtest issues (#7877)
Add annotations for `_ast.Tuple.dims` and `ast.main()`. Add allowlist comments for others.
2022-05-19 10:13:08 +01:00
Alex Waygood 97a74bc1aa Import from collections.abc wherever possible (#7635) 2022-04-18 12:50:37 +02:00
Sebastian Rittau 7a3eb5a481 Use tuple instead of _typing.Tuple in ast (#7639) 2022-04-16 16:15:42 +01:00
Shantanu b88a6f19cd Upgrade black version (#7089) 2022-01-30 16:27:06 -08:00
Shantanu f9cedff5af ast: allow non-literal strings (#6566)
Co-authored-by: hauntsaninja <>
2021-12-10 21:48:46 -08:00
Pavel Karateev 739a052c40 Add more ast.parse() mode overrides (#6522)
eval -> Expression
func_type -> FunctionType
single -> Interactive

We need (simplified) to cover all cases in Python >= 3.8

- 1 case: parse(filename: str = ...)
- 4 cases: parse(filename: str, mode: Literal[...])
- 4 cases: parse(*, mode: Literal[...])
2021-12-10 09:22:23 -08:00
Akuli a5bc1e037f Add mypy error codes to '# type: ignore' comments (#6379) 2021-11-26 07:07:56 +01:00
Alex Waygood fbb89f9fd5 Fix isort w.r.t. _ast/_collections_abc/_tracemalloc/_warnings (#6329) 2021-11-17 08:29:44 -08:00