Comments (4)
This syntax is incompatible with PEP 484. See the paragraph here: https://github.com/python/peps/blob/master/pep-0484.txt#L2097
Relevant quote:
you may list the arguments one per line and add a
# type:
comment
per line after an argument's associated comma
(Emphasis mine)
You may also want to see the discussion in the PR you referenced here: #5 (comment)
from typed_ast.
Great question! The short answer is: no plans currently. Here's why:
First, the major point of departure of typed_ast from ast is that it considers type comments part of the language (which in some senses they are, as specified by PEP 484). As part of this, it considers misplaced type comments to be syntax errors. This is partially due to technical limitations, and I'd likely accept a patch which changed them into warnings, provided it didn't require a massive overhaul.
Second, as @ethanhs mentioned above, PEP 484 is specific about the location of the type comments relative to the comma, so per the spec those type comments are not in a valid position. (IIRC that's partly due to beginning-of-the-line commas being considered unpythonic). It could be valuable for typed_ast to be more flexible here, but I'm not sure it's worth the additional complexity.
The combination of those two factors results in the behavior that you see. Neither of these things has planned development. I've looked at the referenced issue, but could you talk a bit more about why you want this? Maybe a workaround can be found instead.
from typed_ast.
Also, I've always despised the style where the comma comes at the start of the next line. It violates esthetics and good sense.
from typed_ast.
The code sample above is an example of what my unparser generates. Implementing unparsing in that way was... very simple. And I was surprised that typed_ast
errors out on it. But indeed, per PEP 484, a fix should be done not on the parser side, but on the unparser side of things. Thanks for taking time to explain everything!
from typed_ast.
Related Issues (20)
- test_ignores and test_convert_strs fail on ppc64 HOT 5
- Error Installing Pybinsim on Windows with Python 3.8 HOT 1
- Wheel support for aarch64 HOT 7
- typed_ast causes `IndentationError` when using "sphinx-autodoc-typehints" package HOT 2
- Error installing on Python 3.9 HOT 12
- Who has owner permissions on this repo? HOT 7
- Python 3.10 support? - undefined symbol: PyNode_ListTree HOT 3
- ast27 gives syntax error for valid code on s390x HOT 26
- Build failure installing on Python 3.10 HOT 5
- Fails to compile with Apple Silicon compiler HOT 11
- Building wheel in python ``3.10a7`` fail during installation HOT 3
- Older releases crash pip when it tries to build them HOT 2
- Compilation fails on Python 3.11 HOT 2
- Module load fails with Python 3.9.8 (undefined symbol _PyUnicode_DecodeUnicodeEscape) HOT 13
- typed-ast end of life? HOT 12
- Release 1.4.4 HOT 4
- typed_ast end of life (July 2023) HOT 1
- Aarch64 wheels not available on pypi HOT 3
- Install error on Python 3.10.1 windows HOT 4
- Module load fails with Python 3.9.13 (undefined symbol _PyUnicode_DecodeUnicodeEscape)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typed_ast.