@@ -15,93 +15,79 @@ import requests
1515from . import mymodule
1616```
1717
18- # PEP8
18+ ## [ PEP8] ( https://www.python.org/dev/peps/pep-0008/ )
1919
20- ## PEP8 on the Command Line
20+ ### PEP8 on the Command Line
2121
2222Install the [ ` pep8 ` ] ( https://pypi.python.org/pypi/pep8 ) package and run it on
2323one or more directories or files:
2424
2525``` bash
2626pip install pep8
27-
28- # Check a file
29- pep8 portal/core/admin.py
30- # Check a folder
31- pep8 portal/mailers
27+ pep8 portal/core/admin.py # Check a file
28+ pep8 portal/mailers # Check a folder
3229```
3330
34- ## PEP8 in Editors
31+ ### PEP8 in Editors
3532
3633** PyCharm**
3734
3835Enable ` PEP8 Coding Style violation ` and ` PEP8 Naming Convention violation `
39- inspection rules to mark PEP8 issues .
36+ inspection rules.
4037
4138** Sublime Text**
4239
43- Install one of the PEP8 plugins:
44- * [ PEP8 Autoformat] ( https://packagecontrol.io/packages/Python%20PEP8%20Autoformat )
45- * [ Sublime Linter PEP8] ( https://packagecontrol.io/packages/SublimeLinter-pep8 ) .
40+ Install a PEP8 plugins: [ PEP8 Autoformat] ( https://packagecontrol.io/packages/Python%20PEP8%20Autoformat ) or
41+ [ Sublime Linter PEP8] ( https://packagecontrol.io/packages/SublimeLinter-pep8 ) .
4642
47- ## Resolving PEP8 Errors 🛠
43+ ### Resolving PEP8 Errors 🛠
4844
4945Probably the best solution is [ ` autopep8 ` ] ( https://pypi.python.org/pypi/autopep8 ) :
5046
5147``` bash
5248pip install autopep8
49+ autopep8 --diff portal/core/admin.py # Spot issues and generate a diff
50+ autopep8 --in-place portal/core/admin.py # Fix issues in a file
51+ autopep8 -i portal/core/* # Fix issues in a folder
5352
54- # Spot issues and generate a diff
55- autopep8 --diff portal/core/admin.py
56- # Fix issues in a file
57- autopep8 --in-place portal/core/admin.py
58- # Fix issues in a folder
59- autopep8 -i portal/core/*
6053# Fix issues in all files in a directory tree, recursively
6154find portal/core -name ' *.py' -print -exec autopep8 --in-place {} \;
6255```
6356
64- If fixing all PEP8 issues in a file obscures your change , use
65- [ ` pep8radius ` ] ( https://pypi.python.org/pypi/pep8radius ) . This will apply
66- ` autopep8 ` to just the areas of any files that you have changed using ` git ` :
57+ If fixing PEP8 issues obscures changes from reviewers , use
58+ [ ` pep8radius ` ] ( https://pypi.python.org/pypi/pep8radius ) to apply ` autopep8 ` to
59+ only modified areas:
6760
6861``` bash
6962pip install pep8radius
70-
71- # Use pep8radius to fix issues in the code changed. The -vv sets verbose mode so
72- # that the output shows progress.
7363pep8radius -vv --in-place
74-
75- # Now rerun tests, then commit!
7664```
7765
78- Note ` pep8radius ` only looks at files modified but not yet committed,
79- so your workflow should include it * before* commit.
66+ ` pep8radius ` uses ` git ` to check files which have been modified but not commited
67+ so make sure to use it * before* you commit.
8068
81- # Code Inspection 🕵
69+ ## Code Inspection 🕵
8270
8371There are a number of tools that can be used to check Python code for potential
84- errors. You should run these on code that's already been checked for PEP8
85- compliance, so that PEP8 issues don't get flagged.
72+ errors. Run these on code that passes PEP8!
8673
87- ## PyCharm
74+ ### PyCharm
8875
8976The PyCharm IDE has built-in support for Python checking using the * Inspect
90- Code...* tool. The default set of inspections (all of them) is suitable for use
91- on our code.
77+ Code...* tool. The default set of inspections is suitable for use on our code.
9278
93- ## [ PyLint] ( https://docs.pylint.org/ )
79+ ### [ PyLint] ( https://docs.pylint.org/ )
9480
9581PyLint is a Python package for Python source code linting:
9682
9783``` bash
9884pip install pylint
9985
100- # Lint a file
101- pylint portal/core/admin.py
102- # Lint a folder
103- pylint portal/core
104- # Lints a file and output detailed linting results to HTML
86+
87+ pylint portal/core/admin.py # Lint a file
88+ pylint portal/core # Lint a folder
89+
90+ # Lint a file and output details to HTML
10591pylint -f html portal/core/admin.py > pylint.html
10692```
10793
@@ -143,10 +129,9 @@ very, very hard to never emit false positives."_
143129
144130``` bash
145131pip install pyflakes
146- # Check one file
147- pyflakes portal/core/admin.py
148- # Check all the files in a tree
149- pyflakes portal/core
132+
133+ pyflakes portal/core/admin.py # Check one file
134+ pyflakes portal/core # Check all the files in a tree
150135```
151136
152137Pyflakes has no configuration, and there is no way to suppress a warning by
0 commit comments