Skip to content

Commit e1aa0a8

Browse files
authored
Merge pull request #255 from crim-ca/fix-lint-ignore-comments
Address `fix-lint` target problem not respecting ignore comments
2 parents 94f0f3f + 7afde6f commit e1aa0a8

File tree

7 files changed

+41
-11
lines changed

7 files changed

+41
-11
lines changed

Makefile

+13-1
Original file line numberDiff line numberDiff line change
@@ -478,12 +478,24 @@ fix-imports-only: mkdir-reports ## apply import code checks corrections
478478
isort --recursive $(APP_ROOT) \
479479
1> >(tee "$(REPORTS_DIR)/fixed-imports.txt")'
480480

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

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

setup.cfg

+14-10
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

weaver/datatype.py

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class Base(dict):
5757
Explicitly overridden ``getter``/``setter`` attributes are called instead of ``dict``-key ``get``/``set``-item
5858
to ensure corresponding checks and/or value adjustments are executed before applying it to the sub-``dict``.
5959
"""
60+
6061
def __setattr__(self, item, value):
6162
# use the existing property setter if defined
6263
prop = getattr(type(self), item)

weaver/processes/wps_workflow.py

+1
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ class WpsWorkflow(ProcessCWL):
110110
Definition of a ``CWL`` ``workflow`` that can execute ``WPS`` application packages as defined by
111111
:class:`weaver.processes.wps_package.WpsPackage` as job steps.
112112
"""
113+
113114
def __init__(self, toolpath_object, loading_context, get_job_process_definition):
114115
# type: (Dict[Text, Any], LoadingContext, GetJobProcessDefinitionFunction) -> None
115116
super(WpsWorkflow, self).__init__(toolpath_object, loading_context)

weaver/store/mongodb.py

+4
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ class MongodbProcessStore(StoreProcesses, MongodbStore):
177177
"""
178178
Registry for processes. Uses `MongoDB` to store processes and attributes.
179179
"""
180+
180181
def __init__(self, *args, **kwargs):
181182
db_args, db_kwargs = MongodbStore.get_args_kwargs(*args, **kwargs)
182183
StoreProcesses.__init__(self)
@@ -388,6 +389,7 @@ class MongodbJobStore(StoreJobs, MongodbStore):
388389
"""
389390
Registry for process jobs tracking. Uses `MongoDB` to store job attributes.
390391
"""
392+
391393
def __init__(self, *args, **kwargs):
392394
db_args, db_kwargs = MongodbStore.get_args_kwargs(*args, **kwargs)
393395
StoreJobs.__init__(self)
@@ -656,6 +658,7 @@ class MongodbQuoteStore(StoreQuotes, MongodbStore):
656658
"""
657659
Registry for quotes. Uses `MongoDB` to store quote attributes.
658660
"""
661+
659662
def __init__(self, *args, **kwargs):
660663
db_args, db_kwargs = MongodbStore.get_args_kwargs(*args, **kwargs)
661664
StoreQuotes.__init__(self)
@@ -727,6 +730,7 @@ class MongodbBillStore(StoreBills, MongodbStore):
727730
"""
728731
Registry for bills. Uses `MongoDB` to store bill attributes.
729732
"""
733+
730734
def __init__(self, *args, **kwargs):
731735
db_args, db_kwargs = MongodbStore.get_args_kwargs(*args, **kwargs)
732736
StoreBills.__init__(self)

weaver/wps/service.py

+1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ class WorkerService(ServiceWPS):
9999
When receiving ``Execute`` request, convert the XML payload to corresponding JSON and
100100
dispatch it to the Celery Worker to actually process it after job setup for monitoring.
101101
"""
102+
102103
def __init__(self, *_, is_worker=False, settings=None, **__):
103104
super(WorkerService, self).__init__(*_, **__)
104105
self.is_worker = is_worker

weaver/wps_restapi/colander_extras.py

+7
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ class OneOfCaseInsensitive(colander.OneOf):
104104
"""
105105
Validator that ensures the given value matches one of the available choices, but allowing case insensitive values.
106106
"""
107+
107108
def __call__(self, node, value):
108109
if str(value).lower() not in (choice.lower() for choice in self.choices):
109110
return super(OneOfCaseInsensitive, self).__call__(node, value)
@@ -113,6 +114,7 @@ class StringRange(colander.Range):
113114
"""
114115
Validator that provides the same functionalities as :class:`colander.Range` for a numerical string value.
115116
"""
117+
116118
def __init__(self, min=None, max=None, **kwargs):
117119
try:
118120
if isinstance(min, str):
@@ -139,6 +141,7 @@ class SchemeURL(colander.Regex):
139141
:class:`colander.url` [remote http(s)/ftp(s)]
140142
:class:`colander.file_uri` [local file://]
141143
"""
144+
142145
def __init__(self, schemes=None, msg=None, flags=re.IGNORECASE):
143146
if not schemes:
144147
schemes = [""]
@@ -875,6 +878,7 @@ class AnyKeyObject(PermissiveMappingSchema):
875878
This class is only a shorthand definition of ``unknown`` keyword for convenience.
876879
All :class:`colander.MappingSchema` support this natively.
877880
"""
881+
878882
def __init__(self, *args, **kwargs):
879883
kwargs["unknown"] = "preserve"
880884
super(PermissiveMappingSchema, self).__init__(*args, **kwargs)
@@ -1509,6 +1513,7 @@ def _deserialize_keyword(self, cstruct):
15091513

15101514
class KeywordTypeConverter(TypeConverter):
15111515
"""Generic keyword converter that builds schema with a list of sub-schemas under the keyword."""
1516+
15121517
def convert_type(self, schema_node):
15131518
keyword = schema_node.get_keyword_name()
15141519
keyword_schema = {
@@ -1531,6 +1536,7 @@ class OneOfKeywordTypeConverter(KeywordTypeConverter):
15311536
.. seealso::
15321537
- :class:`OneOfKeywordSchema`
15331538
"""
1539+
15341540
def convert_type(self, schema_node):
15351541
# type: (OneOfKeywordSchema) -> Dict
15361542
keyword = schema_node.get_keyword_name()
@@ -1599,6 +1605,7 @@ class VariableObjectTypeConverter(ObjectTypeConverter):
15991605
Updates the mapping object's ``additionalProperties`` for each ``properties``
16001606
that a marked as :class:`VariableSchemaNode`.
16011607
"""
1608+
16021609
def convert_type(self, schema_node):
16031610
converted = super(VariableObjectTypeConverter, self).convert_type(schema_node)
16041611
converted.setdefault("additionalProperties", {})

0 commit comments

Comments
 (0)