Skip to content

Commit cf9be78

Browse files
committed
reapply hack around pycodestyle not respecting noqa E241 via autopep8 (see PyCQA/pycodestyle#996)
1 parent a16dc9f commit cf9be78

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

Makefile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,12 +469,24 @@ fix-imports-only: mkdir-reports ## apply import code checks corrections
469469
isort --recursive $(APP_ROOT) \
470470
1> >(tee "$(REPORTS_DIR)/fixed-imports.txt")'
471471

472+
# FIXME: https://github.com/PyCQA/pycodestyle/issues/996
473+
# Tool "pycodestyle" doesn't respect "# noqa: E241" locally, but "flake8" and other tools do.
474+
# Because "autopep8" uses "pycodestyle", it is impossible to disable locally extra spaces (as in tests to align values).
475+
# Override the codes here from "setup.cfg" because "autopep8" also uses the "flake8" config, and we want to preserve
476+
# global detection of those errors (typos, bad indents), unless explicitly added and excluded for readability purposes.
477+
# WARNING: this will cause inconsistencies between what 'check-lint' detects and what 'fix-lint' can actually fix
478+
_DEFAULT_SETUP_ERROR := E126,E226,E402,F401,W503,W504
479+
_EXTRA_SETUP_ERROR := E241
480+
472481
.PHONY: fix-lint-only
473482
fix-lint-only: mkdir-reports ## fix some PEP8 code style problems automatically
474483
@echo "Fixing PEP8 code style problems..."
475484
@-rm -fr "$(REPORTS_DIR)/fixed-lint.txt"
476485
@bash -c '$(CONDA_CMD) \
477-
autopep8 -v -j 0 -i -r $(APP_ROOT) \
486+
autopep8 \
487+
--global-config "$(APP_ROOT)/setup.cfg" \
488+
--ignore "$(_DEFAULT_SETUP_ERROR),$(_EXTRA_SETUP_ERROR)" \
489+
-v -j 0 -i -r $(APP_ROOT) \
478490
1> >(tee "$(REPORTS_DIR)/fixed-lint.txt")'
479491

480492
# FIXME: move parameters to setup.cfg when implemented (https://github.com/myint/docformatter/issues/10)

setup.cfg

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@ tag = True
55
tag_name = {new_version}
66

77
[bumpversion:file:CHANGES.rst]
8-
search =
8+
search =
99
`Unreleased <https://github.com/crim-ca/weaver/tree/master>`_ (latest)
1010
========================================================================
11-
replace =
11+
replace =
1212
`Unreleased <https://github.com/crim-ca/weaver/tree/master>`_ (latest)
1313
========================================================================
14-
14+
1515
Changes:
1616
--------
1717
- No change.
18-
18+
1919
Fixes:
2020
------
2121
- No change.
22-
22+
2323
`{new_version} <https://github.com/crim-ca/weaver/tree/{new_version}>`_ ({now:%%Y-%%m-%%d})
2424
========================================================================
2525

@@ -40,12 +40,12 @@ search = LABEL version="{current_version}"
4040
replace = LABEL version="{new_version}"
4141

4242
[tool:pytest]
43-
addopts =
43+
addopts =
4444
--strict-markers
4545
--tb=native
4646
weaver/
4747
python_files = test_*.py
48-
markers =
48+
markers =
4949
testbed14: mark test as 'testbed14' validation
5050
functional: mark test as functionality validation
5151
workflow: mark test as workflow execution (E2E)
@@ -70,9 +70,12 @@ exclude = *.egg-info,build,dist,env,tests,./tests,test_*
7070
targets = .
7171

7272
[flake8]
73+
# FIXME: https://github.com/PyCQA/pycodestyle/issues/996
74+
# see Makefile for some specific overrides to avoid false-positive during 'fix-lint'
75+
# new codes must be synced between below list and corresponding one in Makefile
7376
ignore = E126,E226,E402,F401,W503,W504
7477
max-line-length = 120
75-
exclude =
78+
exclude =
7679
src,
7780
.git,
7881
__pycache__,
@@ -88,18 +91,19 @@ max-line-length = 120
8891
ignore-path = docs/build,docs/source/autoapi
8992

9093
[pylint]
94+
# use .pylintrc
9195

9296
[coverage:run]
9397
branch = true
9498
source = ./
9599
include = weaver/*
96-
omit =
100+
omit =
97101
setup.py
98102
docs/*
99103
tests/*
100104

101105
[coverage:report]
102-
exclude_lines =
106+
exclude_lines =
103107
pragma: no cover
104108
raise AssertionError
105109
raise NotImplementedError

0 commit comments

Comments
 (0)