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

PR: Change from pep8 to pycodestyle for style analysis #4218

Merged
merged 8 commits into from
Mar 22, 2017
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion conda.recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ requirements:
- nbconvert
- pygments >=2.0
- sphinx
- pep8
- pycodestyle
- psutil
- pylint
- qtawesome >=0.4.1
Expand Down
2 changes: 1 addition & 1 deletion continuous_integration/circle/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if [ "$CIRCLE_NODE_INDEX" = "3" ]; then
export CONDA_DEPENDENCIES=""
else
export CONDA_DEPENDENCIES_FLAGS="--quiet"
export CONDA_DEPENDENCIES="rope pyflakes sphinx pygments pylint pep8 psutil nbconvert \
export CONDA_DEPENDENCIES="rope pyflakes sphinx pygments pylint pycodestyle psutil nbconvert \
qtawesome pickleshare qtpy pyzmq chardet mock nomkl pandas \
pytest pytest-cov numpydoc scipy cython"
export PIP_DEPENDENCIES="coveralls pytest-qt pytest-xvfb flaky jedi"
Expand Down
2 changes: 1 addition & 1 deletion continuous_integration/conda-recipes/spyder/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ requirements:
- nbconvert
- pygments
- sphinx
- pep8
- pycodestyle
- psutil
- pylint
- qtawesome >=0.4.1
Expand Down
4 changes: 2 additions & 2 deletions create_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def get_stdlib_modules():
shutil.copyfile('scripts/spyder', APP_MAIN_SCRIPT)

APP = [APP_MAIN_SCRIPT]
DEPS = ['pylint', 'logilab', 'astroid', 'pep8', 'setuptools']
DEPS = ['pylint', 'logilab', 'astroid', 'pycodestyle', 'setuptools']
EXCLUDES = DEPS + ['mercurial']
PACKAGES = ['spyder', 'spyder_breakpoints', 'spyder_io_dcm', 'spyder_io_hdf5',
'spyder_profiler', 'spyder_pylint', 'sphinx', 'jinja2', 'docutils',
Expand Down Expand Up @@ -157,7 +157,7 @@ def get_stdlib_modules():
shutil.copytree(osp.join(app_python_lib, p), osp.join(minimal_lib, p))

# Add necessary Python programs to the app
PROGRAMS = ['pylint', 'pep8']
PROGRAMS = ['pylint', 'pycodestyle']
system_progs = [find_program(p) for p in PROGRAMS]
progs_dest = [resources + osp.sep + p for p in PROGRAMS]
for i in range(len(PROGRAMS)):
Expand Down
2 changes: 1 addition & 1 deletion doc/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ The requirements to run Spyder are:

* `Pylint <http://www.logilab.org/project/pylint>`_ -- for static code analysis.

* `Pep8 <https://pypi.python.org/pypi/pep8>`_ -- for style analysis.
* `Pycodestyle <https://pypi.python.org/pypi/pycodestyle>`_ -- for style analysis.

* `Psutil <http://code.google.com/p/psutil/>`_ -- for memory/CPU usage in the status
bar.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def run(self):
'qtconsole>=4.2.0',
'nbconvert',
'sphinx',
'pep8',
'pycodestyle',
'pylint',
'psutil',
'qtawesome>=0.4.1',
Expand Down
4 changes: 2 additions & 2 deletions spyder/plugins/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ def setup_page(self):
codeanalysis.PYFLAKES_REQVER)
pep8_box = newcb(_("Real-time code style analysis"),
'code_analysis/pep8', default=False,
tip=_("<p>If enabled, Python source code will be analyzed"
"using pep8, lines that are not following PEP8 "
tip=_("<p>If enabled, Python source code will be analyzed "
"using pycodestyle, lines that are not following PEP8 "
"style guide will be highlighted.</p>"
"<p><u>Note</u>: add <b>analysis:ignore</b> in "
"a comment to ignore style analysis "
Expand Down
14 changes: 7 additions & 7 deletions spyder/utils/codeanalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ def check_with_pyflakes(source_code, filename=None):
dependencies.add("pyflakes", _("Real-time code analysis on the Editor"),
required_version=PYFLAKES_REQVER)

PEP8_REQVER = '>=0.6'
dependencies.add("pep8", _("Real-time code style analysis on the Editor"),
required_version=PEP8_REQVER)
PYCODESTYLE_REQVER = '>=2.3'
dependencies.add("pycodestyle", _("Real-time code style analysis on the Editor"),
required_version=PYCODESTYLE_REQVER)


def is_pyflakes_installed():
Expand All @@ -117,7 +117,7 @@ def get_checker_executable(name):
return [sys.executable, path1]
elif path2 is not None: # checker.py is available
# Checker package is available but its script has not been
# installed (this works with pep8 but not with pyflakes)
# installed (this works with pycodestyle but not with pyflakes)
return [sys.executable, path2]


Expand All @@ -129,7 +129,7 @@ def check(args, source_code, filename=None, options=None):
if options is not None:
args += options
if any(['pyflakes' in arg for arg in args]):
# Pyflakes requires an ending new line (pep8 don't! -- see Issue 1123)
# Pyflakes requires an ending new line (pycodestyle don't! -- see Issue 1123)
# Note: this code is not used right now as it is faster to invoke
# pyflakes in current Python interpreter (see `check_with_pyflakes`
# function above) than calling it through a subprocess
Expand Down Expand Up @@ -165,9 +165,9 @@ def check(args, source_code, filename=None, options=None):


def check_with_pep8(source_code, filename=None):
"""Check source code with pep8"""
"""Check source code with pycodestyle"""
try:
args = get_checker_executable('pep8')
args = get_checker_executable('pycodestyle')
results = check(args, source_code, filename=filename, options=['-r'])
except Exception:
# Never return None to avoid lock in spyder/widgets/editor.py
Expand Down
2 changes: 1 addition & 1 deletion spyder/widgets/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def run_code_analysis(self, run_pyflakes, run_pep8):
"""Run code analysis"""
run_pyflakes = run_pyflakes and codeanalysis.is_pyflakes_installed()
run_pep8 = run_pep8 and\
codeanalysis.get_checker_executable('pep8') is not None
codeanalysis.get_checker_executable('pycodestyle') is not None
self.pyflakes_results = []
self.pep8_results = []
if self.editor.is_python():
Expand Down