Skip to content

Commit

Permalink
reapply hack around pycodestyle not respecting noqa E241 via autopep8…
Browse files Browse the repository at this point in the history
  • Loading branch information
fmigneault committed May 13, 2021
1 parent a16dc9f commit cf9be78
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -469,12 +469,24 @@ fix-imports-only: mkdir-reports ## apply import code checks corrections
isort --recursive $(APP_ROOT) \
1> >(tee "$(REPORTS_DIR)/fixed-imports.txt")'

# FIXME: https://github.com/PyCQA/pycodestyle/issues/996
# Tool "pycodestyle" doesn't respect "# noqa: E241" locally, but "flake8" and other tools do.
# Because "autopep8" uses "pycodestyle", it is impossible to disable locally extra spaces (as in tests to align values).
# Override the codes here from "setup.cfg" because "autopep8" also uses the "flake8" config, and we want to preserve
# global detection of those errors (typos, bad indents), unless explicitly added and excluded for readability purposes.
# WARNING: this will cause inconsistencies between what 'check-lint' detects and what 'fix-lint' can actually fix
_DEFAULT_SETUP_ERROR := E126,E226,E402,F401,W503,W504
_EXTRA_SETUP_ERROR := E241

.PHONY: fix-lint-only
fix-lint-only: mkdir-reports ## fix some PEP8 code style problems automatically
@echo "Fixing PEP8 code style problems..."
@-rm -fr "$(REPORTS_DIR)/fixed-lint.txt"
@bash -c '$(CONDA_CMD) \
autopep8 -v -j 0 -i -r $(APP_ROOT) \
autopep8 \
--global-config "$(APP_ROOT)/setup.cfg" \
--ignore "$(_DEFAULT_SETUP_ERROR),$(_EXTRA_SETUP_ERROR)" \
-v -j 0 -i -r $(APP_ROOT) \
1> >(tee "$(REPORTS_DIR)/fixed-lint.txt")'

# FIXME: move parameters to setup.cfg when implemented (https://github.com/myint/docformatter/issues/10)
Expand Down
24 changes: 14 additions & 10 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ tag = True
tag_name = {new_version}

[bumpversion:file:CHANGES.rst]
search =
search =
`Unreleased <https://github.com/crim-ca/weaver/tree/master>`_ (latest)
========================================================================
replace =
replace =
`Unreleased <https://github.com/crim-ca/weaver/tree/master>`_ (latest)
========================================================================

Changes:
--------
- No change.

Fixes:
------
- No change.

`{new_version} <https://github.com/crim-ca/weaver/tree/{new_version}>`_ ({now:%%Y-%%m-%%d})
========================================================================

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

[tool:pytest]
addopts =
addopts =
--strict-markers
--tb=native
weaver/
python_files = test_*.py
markers =
markers =
testbed14: mark test as 'testbed14' validation
functional: mark test as functionality validation
workflow: mark test as workflow execution (E2E)
Expand All @@ -70,9 +70,12 @@ exclude = *.egg-info,build,dist,env,tests,./tests,test_*
targets = .

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

[pylint]
# use .pylintrc

[coverage:run]
branch = true
source = ./
include = weaver/*
omit =
omit =
setup.py
docs/*
tests/*

[coverage:report]
exclude_lines =
exclude_lines =
pragma: no cover
raise AssertionError
raise NotImplementedError
Expand Down

0 comments on commit cf9be78

Please sign in to comment.