Commit Graph

32 Commits

Author SHA1 Message Date
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
63db21eaa0 Add __replace__ for AST and AST subclasses (#12486) 2024-08-29 17:25:54 +02:00
Max Muoto
815d8bfb7b ast removals for 3.14 (#12488) 2024-08-10 23:51:19 +03:00
Alex Waygood
9197ace5ec Bump flake8-pyi to 24.6.0 (#12132) 2024-06-12 11:46:23 +01:00
Amin Alaee
124d02034d ast, configparser, glob: Python 3.13 updates (#12050)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-06-01 07:13:10 -07:00
bzoracler
5bd7150139 improvement: Add AST subclass constructors (#11880) 2024-05-18 09:33:07 -04:00
Alex Waygood
a2a6aee892 Fix annotation for ast.alias.name (#11364)
This isn't necessarily always an identifier:

```pycon
>>> print(ast.dump(ast.parse('from typing import *'), indent=2))
Module(
  body=[
    ImportFrom(
      module='typing',
      names=[
        alias(name='*')],
      level=0)],
  type_ignores=[])
>>> '*'.isidentifier()
False
```
2024-02-05 01:42:20 +00: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
Jacob Walls
07d1d2a70c Add attributes to AST type_param classes (#11202) 2023-12-28 13:25:12 +01:00
Alex Waygood
516f665505 Bump flake8-pyi to 23.11.0 (#10997) 2023-11-08 16:01:24 +00:00
bzoracler
3eb9ff7f65 fix __match_args__ attribute name (#10813) 2023-10-01 07:51:02 -07:00
Jelle Zijlstra
628c88d995 Update ast for 3.12 (#10201) 2023-06-02 17:11:13 -07:00
Dominik Lenart
75d5a5b936 Improve typing for ast nodes which represent assignment behaviour (#9326) 2022-12-11 16:54:38 +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
Anh71me
1dd533acc0 stdlib/_ast.pyi: Fix ast.ImportFrom arg module _identifier to str (#8648) 2022-08-30 12:18:28 +02:00
Alex Waygood
fbddd2c4e2 stdlib: enforce CamelCase for type alias names (#8255) 2022-07-07 17:45:23 +02:00
Alex Waygood
8826d3a36f Rename some confusingly named type aliases (#8129) 2022-06-21 20:51:05 +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
Jelle Zijlstra
5c13f8bbce ast: FormattedValue.conversion cannot be None (#7810)
```
In [4]: ast.dump(ast.parse('f"{x!r}"'))
Out[4]: "Module(body=[Expr(value=JoinedStr(values=[FormattedValue(value=Name(id='x', ctx=Load()), conversion=114)]))], type_ignores=[])"

In [5]: ast.dump(ast.parse('f"{x}"'))
Out[5]: "Module(body=[Expr(value=JoinedStr(values=[FormattedValue(value=Name(id='x', ctx=Load()), conversion=-1)]))], type_ignores=[])"
```
(On 3.9 but I don't think this has changed since 3.6.)

The stdlib also assumes this: https://github.com/python/cpython/blob/main/Lib/ast.py#L1211 (`chr(None)` doesn't work).
2022-05-08 19:42:38 -07:00
Alex Waygood
b093c90a94 Use TypeAlias for type aliases where possible, part II (#7667) 2022-04-20 20:02:47 +01:00
Shantanu
b562089d13 ast: add TryStar in py311 (#7646)
Co-authored-by: hauntsaninja <>
2022-04-16 22:13:21 -07:00
Alex Waygood
61b22db692 Add many missing __match_args__ attributes (#7556)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-03-26 19:36:28 +00:00
Shantanu
b88a6f19cd Upgrade black version (#7089) 2022-01-30 16:27:06 -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
Nikita Sobolev
73d5098e0b Use Literal types in ast (#6824) 2022-01-05 11:27:58 +01:00
Akuli
ce11072dbe Big diff: use lower-case list and dict (#5888) 2021-08-08 09:26:35 -07:00
Akuli
1409f6e892 change ast files to use new union syntax (#5880) 2021-08-08 15:47:33 +02:00
Marc Mueller
bad2fea551 Use Literal for MatchSingleton (#5590) 2021-06-08 13:25:41 +02:00
Shantanu
a744c3746f ast: update for py310 (#5293) 2021-05-02 13:02:14 -07:00
Jon Banafato
2686e20060 Add missing tag attribute to TypeIgnore stub (#5238)
This attribute was [added in 3.8]. This change lets mypy resolve the
type correctly instead of failing with an attr-defined error.

[added in 3.8]: https://github.com/python/cpython/pull/13479
2021-04-21 18:48:45 -07:00
Ivan Levkivskyi
16ae4c6120 Re-organize directory structure (#4971)
See discussion in #2491

Co-authored-by: Ivan Levkivskyi <ilevkivskyi@dropbox.com>
2021-01-27 12:00:39 +00:00