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

Exception raised when running on dal.py in web2py #76

Closed
treyhunner opened this issue Jul 21, 2014 · 3 comments
Closed

Exception raised when running on dal.py in web2py #76

treyhunner opened this issue Jul 21, 2014 · 3 comments

Comments

@treyhunner
Copy link

Steps to reproduce

  1. Download the dal.py file from web2py https://code.google.com/p/web2py/source/browse/gluon/dal.py
  2. Run pep257 on this file
  3. Witness the following exception:
Traceback (most recent call last):
  File "/usr/bin/pep257", line 8, in <module>
    sys.exit(main(*parse_options()))
  File "/usr/lib/python2.7/site-packages/pep257.py", line 411, in main
    for error in check(collected, ignore=options.ignore.split(',')):
  File "/usr/lib/python2.7/site-packages/pep257.py", line 394, in check
    for error in PEP257Checker().check_source(source, filename):
  File "/usr/lib/python2.7/site-packages/pep257.py", line 440, in check_source
    module = parse(StringIO(source), filename)
  File "/usr/lib/python2.7/site-packages/pep257.py", line 181, in __call__
    return self.parse_module()
  File "/usr/lib/python2.7/site-packages/pep257.py", line 252, in parse_module
    children = list(self.parse_definitions(Module, all=True))
  File "/usr/lib/python2.7/site-packages/pep257.py", line 212, in parse_definitions
    for definition in self.parse_definitions(class_):
  File "/usr/lib/python2.7/site-packages/pep257.py", line 209, in parse_definitions
    yield self.parse_definition(class_._nest(token.value))
  File "/usr/lib/python2.7/site-packages/pep257.py", line 268, in parse_definition
    children = list(self.parse_definitions(class_))
  File "/usr/lib/python2.7/site-packages/pep257.py", line 209, in parse_definitions
    yield self.parse_definition(class_._nest(token.value))
  File "/usr/lib/python2.7/site-packages/pep257.py", line 269, in parse_definition
    assert self.current.kind == tk.DEDENT
AttributeError: 'NoneType' object has no attribute 'kind'
@Nurdok
Copy link
Member

Nurdok commented Jul 21, 2014

I'm debugging this as we speak.
I found out the problem, still working on a solution.
The problem is after a definition, we expect an indent followed by some stuff and then a dedent.
Unfortunately this doesn't take one-liner definitions into account.
The following test case reproduces the error:

def foo(): return 4

Nurdok added a commit to Nurdok/pydocstyle that referenced this issue Jul 21, 2014
@treyhunner
Copy link
Author

This is not holding up my own use of pep257, it's simply a bug I had noticed when I accidentally ran it against dal.py from web2py. I appreciate the fast response though @Nurdok.

@Nurdok
Copy link
Member

Nurdok commented Jul 21, 2014

Thanks for taking the time to report this. I fixed this and opened a pull request.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants