Commit Graph

29 Commits

Author SHA1 Message Date
Jelle Zijlstra
0142a87da8 adjust isort config (#4290)
Fixes #4288.

- Default imports to THIRD_PARTY, so in effect we merge the FIRST_PARTY and THIRD_PARTY stubs. This means import order is no longer affected by whether typing_extensions is installed locally.
- Treat typing_extensions, _typeshed and some others as standard library modules.

Note that isort master is very different from the latest release; we'll have to do something
different if and when the next isort release comes out.
2020-06-29 00:00:21 -07:00
Jelle Zijlstra
5d553c9584 apply black and isort (#4287)
* apply black and isort

* move some type ignores
2020-06-28 13:31:00 -07:00
Sebastian Rittau
89d3a55f1a Preparations for the Big Reformat (#4228)
A few comments between imports were removed or moved to the top of the
import block, due to behavioral differences between black and isort. See
psf/black#251 for details.

In two instances @overloads at the top of the file needed to be moved
due to psf/black#1490.
2020-06-14 07:58:26 -07:00
Jelle Zijlstra
44a852dff5 Literal: always import from typing_extensions for simplicity (#4219) 2020-06-10 21:23:58 -07:00
Shantanu
5a3a47264f ast: add indent to dump in py39 (#4007)
Co-authored-by: hauntsaninja <>
2020-05-16 17:03:03 -07:00
Shantanu
061e58deb8 _ast: fix version availability for py39, fix up some visit_ methods (#4008) 2020-05-16 17:02:08 -07:00
Ran Benita
92d53086be stdlib/3/ast: add visit_* methods to NodeVisitor (#3796)
NodeVisitor recurses over an AST tree. When encountering a node, it
checks if a method called `visit_{node.__class__.__name__}` exists, and
calls it if so, otherwise calls the generic visitor.

Add the possible methods to NodeVisitor. This is not exactly correct,
since the methods don't *actually* exist on NodeVisitor, e.g.
`NodeVisitor().visit_Module(...)` doesn't work. But it's nice for
subclasses to know which methods they can override and which type they
should have.
2020-03-06 13:15:04 +01:00
Shantanu
1fb46cb4d1 ast: add visit_Constant to NodeVisitor (#3767) 2020-02-21 20:26:15 -08:00
Shantanu
f4787297e9 ast: update for py38 (#3698) 2020-02-01 09:25:56 -08:00
Shantanu
ba8b2585c6 ast: some fixes for py38 (#3625)
* ast: make parse args keyword-only
* ast: get_source_segment is py38 on
2020-01-20 08:50:59 +01:00
Batuhan Taşkaya
387ea1512a Add ast.unparse (#3557) 2019-12-26 16:06:10 +01:00
Michael J. Sullivan
7c6104ddfe Don't shadow ast.Tuple with typing.Tuple (#3376) 2019-10-16 12:39:56 -07:00
Sebastian Rittau
62bbdf856c Add several Python 3.8 annotations (#3347) 2019-10-12 19:36:56 +02:00
Sebastian Rittau
628eee29f7 Use Literal in a few more places (#3176) 2019-08-10 13:08:18 -07:00
Carl Meyer
fcb97fe8f1 Overload ast.parse to recognize that mode=exec means Module return. (#3039) 2019-06-17 23:27:14 +02:00
Michael J. Sullivan
cc596aefbc Add a type: ignore as a hacky workaround for some mypy bazel issues (#2887) 2019-03-27 15:10:47 -07:00
Guido van Rossum
6b6d8c82ac Support new ast features and node types introduced in Python 3.8 (#2859)
Had to adjust the return type of ast.parse() from Module to AST, which
is more truthful anyways.
2019-03-12 16:34:56 +01:00
Jukka Lehtosalo
306b4694ae Remove redundant definition of ast.PyCF_ONLY_AST (#2803)
This gets imported from `_ast`, so the definition was
redundant. This causes problems with the new mypy semantic
analyzer, as it will flag the redefinition as an error.
2019-02-20 17:12:11 +00:00
Tomer Keren
d9a202e352 Make appropriate ast methods generic (#2715)
Closes #2714
2018-12-24 20:03:09 +01:00
Guido van Rossum
e08a5ac367 Tweak how ast.pyi imports typing (#2668)
When we import typeshed internally at Dropbox, somehow the fact that
these files are all stubs gets lost (it's a long story...).  This
causes errors like this:

  .../stdlib/2/ast.pyi:6: error: Name 'typing' already defined (by an import)

The quickest way around this is to rename the import to _typing.
2018-12-04 17:25:23 +01:00
Hannes Karppila
4d86092df0 Fix return type of ast.NodeTransformer.generic_visit (#2486) 2018-10-19 08:50:50 +02:00
Guido van Rossum
d854d7e2a0 Revert "Fix signature of generic_visit method (#2100)" (#2101)
This reverts commit 39576c5d41.

I merged too soon -- tests are failing.
2018-05-07 11:21:19 -07:00
Thomas Schaper
39576c5d41 Fix signature of generic_visit method (#2100)
This methods returns something that has the same type as the first argument.
Fixes #2085.
2018-05-07 11:20:20 -07:00
Svyatoslav Ilinskiy
3f9fafbbb7 Re-export code from _ast into ast. (#1515)
After mypy [started hiding](https://github.com/python/mypy/pull/3706) imported names in stubs unless `from ... import ...` is used, we found an error with stubs of ast module. 

It looks like ast module should re-export everything in `_ast` and according to PEP 484, it can do that by doing `from _ast import *`, so this is what this PR does.
2017-08-03 15:57:20 -07:00
Ethan
3b30996733 Change ast's parse signature to return Module (#836) 2017-01-17 09:49:41 -08:00
Lukasz Langa
fe0e3744cc Fixing flake8 E261 errors 2016-12-19 22:09:35 -08:00
Lukasz Langa
b84f20a011 Fixing flake8 W errors 2016-12-19 21:52:56 -08:00
TrueBrain
15ec66cdd6 Consider __doc__ always Optional. (#641)
python/mypy#2380 showed a discrepancy between object and FunctionType in stdlib2. The first defined __doc__ to be str, the second Optional[str]. As FunctionType depends on object, this is no longer valid.

As suggested by @gvanrossum in python/mypy#2380, all __doc__ should be considered Optional.

(Final verdict was just to remove most __doc__ attributes since it's inherited from object.)
2016-10-30 11:48:23 -07:00
David Fisher
e8f626536e Add Python 3 ast module; update Python 2.7 ast module; fixup typed_ast (#170) 2016-05-04 10:40:36 -07:00