pythonpep8-checker

Scan complete directory tree using pep8


I'm using pep8 to check for coding guidelines. I am getting results only for the current directory. And not all directory or sub directory inside it. How to do that?

When running it from the level of container/project, I don't get pyc files' errors. When I run it from container/project/app, I get the pyc files' errors. Following is the tree structure:

container
      project
            app
                  __init__.py
                  admin.py
                  models.py
                  views.py
                  tests.py
                  file1.py

            project
                  __init__.py
                  urls.py
                  wsgi.py
                  settings.py

            templates
                  __init__.py
                  home.html
                  page1.html

            manage.py
            pylintrc
            setup.cfg

      README

And following is the content of setup.cfg:

[pep8]
ignore=E122,E123,E128
exclude=pylintrc,setup.cfg
max-line-length=80

Solution

  • The pep8 command does scan subdirectories automatically. It'll look for any file matching the patterns named in the --filename option (the default is *.py).

    Scan your project with pep8 . or pep8 directoryname.

    If you run pep8 * in a directory, then your shell expands the * into all files in the current directory, so pep8 will scan all those files even if they don't match the --filename file patterns. That could include files like setup.cfg, which is not a file you'd want to scan.

    Any subdirectories of the current directory would still be scanned too (as they are named in the list of names the shell produces when you use the * wildcard), but then pep8 will only look for files matching the --filename option again.