Skip to content
This repository was archived by the owner on Apr 2, 2019. It is now read-only.

Commit 4049041

Browse files
committed
Use standard pep8 configuration
1 parent 8bfd4d9 commit 4049041

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,15 @@ By default Python Checker will use the version of Python that came with Sublime
2929
```
3030

3131
This is compatible with other plugins including [SublimeJEDI](https://github.com/srusskih/SublimeJEDI).
32+
33+
PEP8 checks
34+
-----------
35+
36+
Use the standard `pep8` [configuration files](http://pep8.readthedocs.org/en/latest/intro.html#configuration) to control the behaviour including skipping some checks. An example project configration might look like this:
37+
38+
```ini
39+
# setup.cfg or tox.ini
40+
[pep8]
41+
ignore = E501,W191
42+
max-line-length = 120
43+
```

checker.py

+10-9
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
from pep8 import pep8
1313
from pyflakes import checker
1414

15-
PEP8_IGNORED = {'E501', 'W191'}
16-
1715
Problem = namedtuple('Problem', 'level lineno offset message')
1816

1917

@@ -52,7 +50,9 @@ def get_flakes(source, filename):
5250

5351

5452
def get_style_problems(source, filename):
55-
guide = pep8.StyleGuide(reporter=Pep8Report, ignore=PEP8_IGNORED)
53+
config, _args = pep8.process_options([filename], config_file=True)
54+
config = dict(config.__dict__, reporter=Pep8Report)
55+
guide = pep8.StyleGuide(**config)
5656
lines = source.splitlines(True)
5757
checker = pep8.Checker(filename, lines, guide.options)
5858
checker.check_all()
@@ -64,24 +64,25 @@ def get_external(source, filename, executable):
6464
import subprocess
6565
with tempfile.NamedTemporaryFile() as tf:
6666
tf.write(source.encode('utf-8'))
67-
output = subprocess.check_output([executable, __file__, tf.name])
67+
output = subprocess.check_output([executable, __file__, tf.name,
68+
filename])
6869
problems = json.loads(output.decode('utf-8'))
6970
problems = [Problem(*p) for p in problems]
7071
return problems
7172

7273

73-
def main(filename):
74+
def main(filename, path):
7475
import json
7576
with open(filename, 'rb') as f:
7677
source = f.read()
7778
if sys.version_info[0] >= 3:
7879
source = source.decode('utf-8')
79-
problems = get_problems(source, filename)
80+
problems = get_problems(source, path)
8081
json.dump(problems, sys.stdout)
8182

8283

8384
if __name__ == '__main__':
84-
if len(sys.argv) == 2:
85-
main(sys.argv[1])
85+
if len(sys.argv) == 3:
86+
main(sys.argv[1], sys.argv[2])
8687
else:
87-
print('Usage: %s %s <filename>' % (sys.executable, sys.argv[0],))
88+
print('Usage: %s %s <filename> <path>' % (sys.executable, sys.argv[0]))

0 commit comments

Comments
 (0)