Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.

pydocstyle fails on "raise X from Y" #196

Closed
Nurdok opened this issue Jul 2, 2016 · 2 comments · Fixed by #200
Closed

pydocstyle fails on "raise X from Y" #196

Nurdok opened this issue Jul 2, 2016 · 2 comments · Fixed by #200

Comments

@Nurdok
Copy link
Member

Nurdok commented Jul 2, 2016

The reason is that the "from" keyword triggers a "from X import Y" parsing, which fails.

C:\Users\rachum\code\testing_grounds>cat example.py
raise RuntimeError() from None
C:\Users\rachum\code\testing_grounds>python example.py  # this syntax is legal in Python 3
Traceback (most recent call last):
  File "example.py", line 1, in <module>
    raise RuntimeError() from None
RuntimeError

C:\Users\rachum\code\testing_grounds>pydocstyle example.py
Traceback (most recent call last):
  File "c:\users\rachum\appdata\local\programs\python\python35-32\lib\runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\rachum\appdata\local\programs\python\python35-32\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\rachum\AppData\Local\Programs\Python\Python35-32\Scripts\pydocstyle.exe\__main__.py", line 9, in <module>
  File "c:\users\rachum\appdata\local\programs\python\python35-32\lib\site-packages\pydocstyle.py", line 1745, in main
    sys.exit(run_pydocstyle(use_pep257))
  File "c:\users\rachum\appdata\local\programs\python\python35-32\lib\site-packages\pydocstyle.py", line 1360, in run_pydocstyle
    errors.extend(check((filename,), select=checked_codes))
  File "c:\users\rachum\appdata\local\programs\python\python35-32\lib\site-packages\pydocstyle.py", line 1297, in check
    for error in PEP257Checker().check_source(source, filename):
  File "c:\users\rachum\appdata\local\programs\python\python35-32\lib\site-packages\pydocstyle.py", line 1398, in check_source
    module = parse(StringIO(source), filename)
  File "c:\users\rachum\appdata\local\programs\python\python35-32\lib\site-packages\pydocstyle.py", line 276, in __call__
    return self.parse_module()
  File "c:\users\rachum\appdata\local\programs\python\python35-32\lib\site-packages\pydocstyle.py", line 429, in parse_module
    children = list(self.parse_definitions(Module, all=True))
  File "c:\users\rachum\appdata\local\programs\python\python35-32\lib\site-packages\pydocstyle.py", line 376, in parse_definitions
    self.parse_from_import_statement()
  File "c:\users\rachum\appdata\local\programs\python\python35-32\lib\site-packages\pydocstyle.py", line 510, in parse_from_import_statement
    is_future_import = self._parse_from_import_source()
  File "c:\users\rachum\appdata\local\programs\python\python35-32\lib\site-packages\pydocstyle.py", line 525, in _parse_from_import_source
    self.check_current(value='import')
  File "c:\users\rachum\appdata\local\programs\python\python35-32\lib\site-packages\pydocstyle.py", line 501, in check_current
    assert kind_valid and value_valid, msg
AssertionError:
Unexpected token at line 2:

In file: example.py

Got kind tk.ENDMARKER
Got value
@blueyed
Copy link
Contributor

blueyed commented Sep 5, 2016

Should this be on the 1.1.0 milestone? (https://github.com/PyCQA/pydocstyle/milestone/4)

Any progress / insights on this one?

@Nurdok
Copy link
Member Author

Nurdok commented Sep 5, 2016

This is solved in #200 and it will definitely be in the next release - still working on the PR though. Hopefully it will be done this week.

@Nurdok Nurdok added this to the pydocstyle 1.1.0 milestone Sep 5, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants