Skip to content
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

Failure if triple quotes not matched in function docstring #306

Closed
montefra opened this issue Jul 25, 2014 · 2 comments
Closed

Failure if triple quotes not matched in function docstring #306

montefra opened this issue Jul 25, 2014 · 2 comments
Assignees
Labels
Milestone

Comments

@montefra
Copy link

I'm writing a module, at which end I have a definition of a function with a doc string within triple quotes without any implementation. I've run pep8 (v1.5.7) on it and I get the following error:

Traceback (most recent call last):
  File "~/.local/bin/pep8", line 11, in 
    sys.exit(_main())
  File "~/.local/lib/python2.7/site-packages/pep8.py", line 1929, in _main
    report = pep8style.check_files()
  File "~/.local/lib/python2.7/site-packages/pep8.py", line 1672, in check_files
    runner(path)
  File "~/.local/lib/python2.7/site-packages/pep8.py", line 1684, in input_file
    return fchecker.check_all(expected=expected, line_offset=line_offset)
  File "~/.local/lib/python2.7/site-packages/pep8.py", line 1456, in check_all
    self.check_logical()
  File "~/.local/lib/python2.7/site-packages/pep8.py", line 1328, in check_logical
    (start_row, start_col) = mapping[0][1]
TypeError: 'NoneType' object has no attribute '__getitem__'

After some tests, I found that it's caused by not correctly matching the docstring quotes. Can be tested simply by running pep8 on

def foo():
    """test docstring""'

Notice the last being ' not ".
If I use single quotes, nothing happens.

The correct behaviour should be something like:

E901 TokenError: EOF in multi-line string

i.e. when a string is not correctly quoted at the end of the file

@florentx florentx added this to the 1.6 milestone Jul 26, 2014
@florentx florentx added the bug label Jul 26, 2014
@drimer
Copy link

drimer commented Sep 1, 2014

I've come across the same issue with a different case.

My code looks like something like this:

def foo():
    pass
\

def bar():
    pass

Although that's a stupid thing to do, the fact that flake8 never ends execution and doesn't report this properly has caused me some trouble.

@IanLee1521
Copy link
Member

Resolved with commit e585618

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

4 participants