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

Trying to reproduce flake8 weirdness #7

Closed
wants to merge 1 commit into from

Conversation

doismellburning
Copy link
Owner

flake8 should have complained because of a missing blank line before the
class definition (my 5-line minimal test is a 6-line minimal test).

Lets try to make it really unhappy...

flake8 should have complained because of a missing blank line before the
class definition (my 5-line minimal test is a 6-line minimal test).

Lets try to make it _really_ unhappy...
@doismellburning
Copy link
Owner Author

According to https://circleci.com/gh/doismellburning/cookiecutter-django/52:

flake8 runtests: PYTHONHASHSEED='2434440579'
flake8 runtests: commands[0] | flake8 --max-line-length 120 --exclude migrations,settings.py loremipsum selenium

snip

  flake8: commands succeeded

:(

@doismellburning
Copy link
Owner Author

Similarly, manually:

$ rm -rf loremipsum/
$ tox
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pkgutil.py:186: ImportWarning: Not importing directory '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/mpl_toolkits': missing __init__.py
  file, filename, etc = imp.find_module(subname, path)
py27 create: cookiecutter-django/.tox/py27
py27 installdeps: -rcookiecutter-django/requirements-test.txt
py27 runtests: PYTHONHASHSEED='408350793'
py27 runtests: commands[0] | cookiecutter --no-input .
__________________________________________________________________________________________________________________ summary ___________________________________________________________________________________________________________________
  py27: commands succeeded
  congratulations :)

$ cd loremipsum/
$ tox -e flake8
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pkgutil.py:186: ImportWarning: Not importing directory '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/mpl_toolkits': missing __init__.py
  file, filename, etc = imp.find_module(subname, path)
flake8 create: cookiecutter-django/loremipsum/.tox/flake8
flake8 installdeps: -r/cookiecutter-django/loremipsum/requirements.txt, -rcookiecutter-django/loremipsum/requirements-test.txt
flake8 runtests: PYTHONHASHSEED='3383096611'
flake8 runtests: commands[0] | flake8 --max-line-length 120 --exclude migrations,settings.py loremipsum selenium
__________________________________________________________________________________________________________________ summary ___________________________________________________________________________________________________________________
  flake8: commands succeeded
  congratulations :)

$ .tox/flake8/bin/flake8 --verbose loremipsum/loremipsum/tests/test_basic.py 
local configuration: in cookiecutter-django/loremipsum
checking loremipsum/loremipsum/tests/test_basic.py
$ echo $?
0

$ cat loremipsum/loremipsum/tests/test_basic.py                                                                                            
from django.test import TestCase

class BasicTestCase(TestCase):
  def test_getting_root(self):
    self.client.get('/')

@doismellburning
Copy link
Owner Author

$ .tox/flake8/bin/pip freeze
Django==1.8.3
coverage==4.0a6
dj-database-url==0.3.0
dj-email-url==0.0.2
django-cache-url==0.8.0
django12factor==1.3
flake8==2.4.1
mccabe==0.3.1
pep8==1.5.7
pyflakes==0.8.1
six==1.9.0
whitenoise==2.0.2
wsgiref==0.1.2

@doismellburning
Copy link
Owner Author

$ .tox/flake8/bin/pep8 loremipsum/loremipsum/tests/test_basic.py 
loremipsum/loremipsum/tests/test_basic.py:3:1: E302 expected 2 blank lines, found 1
loremipsum/loremipsum/tests/test_basic.py:4:3: E111 indentation is not a multiple of four

That's reassuring!

@inglesp
Copy link

inglesp commented Aug 5, 2015

I can reproduce. Looks like there might be some kind of snafoozle with tox and python versions.

16:04:38 ~/tmp $ git clone git@github.com:doismellburning/cookiecutter-django.git
Cloning into 'cookiecutter-django'...
remote: Counting objects: 187, done.
remote: Compressing objects: 100% (13/13), done.
remote: Total 187 (delta 62), reused 58 (delta 58), pack-reused 115
Receiving objects: 100% (187/187), 19.53 KiB | 0 bytes/s, done.
Resolving deltas: 100% (101/101), done.
Checking connectivity... done.
16:04:44 ~/tmp $ cd cookiecutter-django/
16:04:46 ~/tmp/cookiecutter-django $ mkvirtualenv cookiecutter-django
New python executable in cookiecutter-django/bin/python2.7
Also creating executable in cookiecutter-django/bin/python
Installing setuptools, pip, wheel...done.
(cookiecutter-django)16:04:56 ~/tmp/cookiecutter-django $ pip install -r requirements-test.txt 
Collecting cookiecutter==1.0.0 (from -r requirements-test.txt (line 1))
  Using cached cookiecutter-1.0.0-py2.py3-none-any.whl
Collecting PyYAML>=3.10 (from cookiecutter==1.0.0->-r requirements-test.txt (line 1))
Collecting mock (from cookiecutter==1.0.0->-r requirements-test.txt (line 1))
  Using cached mock-1.3.0-py2.py3-none-any.whl
Collecting click<4.0 (from cookiecutter==1.0.0->-r requirements-test.txt (line 1))
  Using cached click-3.3-py2.py3-none-any.whl
Collecting binaryornot>=0.2.0 (from cookiecutter==1.0.0->-r requirements-test.txt (line 1))
Collecting jinja2>=2.7 (from cookiecutter==1.0.0->-r requirements-test.txt (line 1))
  Using cached Jinja2-2.8-py2.py3-none-any.whl
Collecting funcsigs (from mock->cookiecutter==1.0.0->-r requirements-test.txt (line 1))
  Using cached funcsigs-0.4-py2.py3-none-any.whl
Collecting pbr>=0.11 (from mock->cookiecutter==1.0.0->-r requirements-test.txt (line 1))
  Using cached pbr-1.4.0-py2.py3-none-any.whl
Collecting six>=1.7 (from mock->cookiecutter==1.0.0->-r requirements-test.txt (line 1))
  Using cached six-1.9.0-py2.py3-none-any.whl
Collecting MarkupSafe (from jinja2>=2.7->cookiecutter==1.0.0->-r requirements-test.txt (line 1))
Installing collected packages: PyYAML, funcsigs, pbr, six, mock, click, binaryornot, MarkupSafe, jinja2, cookiecutter
Successfully installed MarkupSafe-0.23 PyYAML-3.11 binaryornot-0.3.0 click-3.3 cookiecutter-1.0.0 funcsigs-0.4 jinja2-2.8 mock-1.3.0 pbr-1.4.0 six-1.9.0
(cookiecutter-django)16:05:02 ~/tmp/cookiecutter-django $ tox
py27 create: /Users/peteringlesby/tmp/cookiecutter-django/.tox/py27
py27 installdeps: -r/Users/peteringlesby/tmp/cookiecutter-django/requirements-test.txt
py27 runtests: PYTHONHASHSEED='2081064214'
py27 runtests: commands[0] | cookiecutter --no-input .
_________________________________________________________________________________________________ summary __________________________________________________________________________________________________
  py27: commands succeeded
  congratulations :)
(cookiecutter-django)16:05:35 ~/tmp/cookiecutter-django $ cd loremipsum/
(cookiecutter-django)16:05:45 ~/tmp/cookiecutter-django/loremipsum $ flake8 --exclude migrations,settings.py
(cookiecutter-django)16:05:49 ~/tmp/cookiecutter-django/loremipsum $ which flake8
/usr/local/bin/flake8
(cookiecutter-django)16:06:08 ~/tmp/cookiecutter-django/loremipsum $ cat $(which flake8)
#!/usr/local/opt/python3/bin/python3.4
# EASY-INSTALL-ENTRY-SCRIPT: 'flake8==2.2.5','console_scripts','flake8'
__requires__ = 'flake8==2.2.5'
import sys
from pkg_resources import load_entry_point

if __name__ == '__main__':
    print(sys.version_info)
    sys.exit(
        load_entry_point('flake8==2.2.5', 'console_scripts', 'flake8')()
    )
(cookiecutter-django)16:06:13 ~/tmp/cookiecutter-django/loremipsum $ flake8 --exclude migrations,settings.py
sys.version_info(major=3, minor=4, micro=2, releaselevel='final', serial=0)

@doismellburning
Copy link
Owner Author

$ tox --version
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pkgutil.py:186: ImportWarning: Not importing directory '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/mpl_toolkits': missing __init__.py
  file, filename, etc = imp.find_module(subname, path)
1.8.1 imported from /Library/Python/2.7/site-packages/tox/__init__.pyc

@doismellburning
Copy link
Owner Author

@inglesp Yay it's not just me <3 Thanks!

@doismellburning
Copy link
Owner Author

I have a suspicion it's somehow related to the multiple tox.inis in the ancestry, but I deleted the parent one locally and it made no difference...

@rfleschenberg
Copy link

(cookiecutter-django)[rene@rex loremipsum]$ flake8 && echo $?
0

But:

(cookiecutter-django)[rene@rex loremipsum]$ pep8 
./loremipsum/loremipsum/tests/test_basic.py:3:1: E302 expected 2 blank lines, found 1

@rfleschenberg
Copy link

I don't yet understand how, but the problem is apparently caused by this trailing comma in the generated tox.ini:

[flake8]
ignore =
    E126,
    E127,
    E128,

@inglesp
Copy link

inglesp commented Aug 5, 2015

Chapeau @rfleschenberg, that's hilarious.

@doismellburning
Copy link
Owner Author

20:30 < moldy> doismellburning: wtf. flake8 behaves differently if tox.ini is present.

So it does! 😡

$ rm tox.ini
$ rm ../tox.ini
$ .tox/flake8/bin/flake8 loremipsum/loremipsum/tests/test_basic.py 
loremipsum/loremipsum/tests/test_basic.py:3:1: E302 expected 2 blank lines, found 1
loremipsum/loremipsum/tests/test_basic.py:4:3: E111 indentation is not a multiple of four

@doismellburning
Copy link
Owner Author

@rfleschenberg ... <3

@doismellburning
Copy link
Owner Author

I managed to write #7 (comment) before seeing #7 (comment) oops

@rfleschenberg
Copy link

This disables all PEP8 checks, btw :)

The problem is this: the trailing comma will be parsed as an empty ignore option. So flake8 passes this tuple of errors to ignore to pep8: ('\nE126', '\nE127', '\nE128', '')

Then, in pep8.py, ignore_code() checks wether a given code should be ignored:

        return (code.startswith(self.options.ignore) and
                not code.startswith(self.options.select))

Because every string starts with the empty string, the first part of this check will always be true, so all checks that are not in options.select will be ignored.

@rfleschenberg
Copy link

Oh btw, seeing those newlines before the error codes, is there another bug here? Looks like the codes that should be ignored won't? :)

@doismellburning
Copy link
Owner Author

<3 thanks all

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 this pull request may close these issues.

3 participants