Skip to content

Problem with dangling comma #434

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
srittau opened this issue Oct 13, 2019 · 0 comments
Closed

Problem with dangling comma #434

srittau opened this issue Oct 13, 2019 · 0 comments
Assignees
Labels

Comments

@srittau
Copy link
Contributor

srittau commented Oct 13, 2019

From python/typeshed#3358, CI: https://travis-ci.org/python/typeshed/jobs/597311318

Please consider the following file foo.pyi:

ExceptHookArgs = NamedTuple(
    "ExceptHookArgs",
    [
        ("exc_type", Type[BaseException]),
        ("exc_value", Optional[BaseException]),
        ("exc_traceback", Optional[TracebackType]),
        ("thread", Optional[Thread]),
    ],
)

pytype 2019.09.17 (Python 3.7.3) complains:

$ pytype-single --parse-pyi --module-name=foo -V3.6 foo.pyi 
Traceback (most recent call last):
  File "/home/srittau/Projekte/typeshed/.venv/lib/python3.7/site-packages/pytype/pyi/parser.py", line 430, in parse
    defs = parser_ext.parse(self, src)
pytype.pyi.parser.ParseError: ParseError: syntax error, unexpected ',', expecting ')'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./.venv/bin/pytype-single", line 11, in <module>
    load_entry_point('pytype==2019.9.17', 'console_scripts', 'pytype-single')()
  File "/home/srittau/Projekte/typeshed/.venv/lib/python3.7/site-packages/pytype/main.py", line 88, in main
    return _run_pytype(options)
  File "/home/srittau/Projekte/typeshed/.venv/lib/python3.7/site-packages/pytype/main.py", line 96, in _run_pytype
    unused_ast = io.parse_pyi(options)
  File "/home/srittau/Projekte/typeshed/.venv/lib/python3.7/site-packages/pytype/io.py", line 263, in parse_pyi
    ast = loader.load_file(options.module_name, options.input)
  File "/home/srittau/Projekte/typeshed/.venv/lib/python3.7/site-packages/pytype/load_pytd.py", line 241, in load_file
    python_version=self.python_version)
  File "/home/srittau/Projekte/typeshed/.venv/lib/python3.7/site-packages/pytype/pyi/parser.py", line 1250, in parse_file
    src, name, filename)
  File "/home/srittau/Projekte/typeshed/.venv/lib/python3.7/site-packages/pytype/pyi/parser.py", line 440, in parse
    column=self._error_location[1], text=text)
pytype.pyi.parser.ParseError:   File: "foo.pyi", line 8
    ],
     ^
ParseError: syntax error, unexpected ',', expecting ')'

I can work around this for now, but black will re-insert the comma, so that will cause us problems in the future.

srittau added a commit to srittau/typeshed that referenced this issue Oct 13, 2019
@rchen152 rchen152 added the bug label Oct 15, 2019
@rchen152 rchen152 self-assigned this Oct 15, 2019
rchen152 added a commit that referenced this issue Oct 15, 2019
rchen152 added a commit that referenced this issue Oct 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants