Skip to content

Commit

Permalink
[pylint] Refactor pylint configuration
Browse files Browse the repository at this point in the history
Also fix tox issues with posargs and further fine tuning

Signed-off-by: Arif Ali <arif.ali@canonical.com>
  • Loading branch information
arif-ali authored and TurboTurtle committed May 23, 2024
1 parent 22cea2f commit e89ccce
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 48 deletions.
97 changes: 97 additions & 0 deletions pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
[MAIN]
# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the
# number of processors available to use.
jobs=0

# When enabled, pylint would attempt to guess common misconfiguration and emit
# user-friendly hints instead of false-positive error messages.
suggestion-mode=yes

[FORMAT]
# Maximum number of characters on a single line.
max-line-length=79

[REPORTS]
# Activate the evaluation score.
score=yes

[MESSAGES CONTROL]
disable=
C0103, # invalid-name
C0114, # missing-module-docstring
C0115, # missing-class-docstring
C0116, # missing-function-docstring
C0302, # too-many-lines
C0415, # import-outside-toplevel
R0401, # cyclic-import
R0801, # duplicate-code
R0902, # too-many-instance-attributes
R0903, # too-few-public-methods
R0904, # too-many-public-methods
R0911, # too-many-return-statements
R0912, # too-many-branches
R0913, # too-many-arguments
R0914, # too-many-locals
R0915, # too-many-statements
R1702, # too-many-nested-blocks
W0201, # attribute-defined-outside-init
W0511, # fixme
###################### VV things we should fix VV
W0613, # unused-argument
W0612, # unused-variable
R1705, # no-else-return
W0719, # broad-exception-raised
W1203, # logging-fstring-interpolation
W1406, # redundant-u-string-prefix
R1732, # consider-using-with
W1514, # unspecified-encoding
W0107, # unnecessary-pass
W0718, # broad-exception-caught
W0102, # dangerous-default-value
C0325, # superfluous-parens
E1111, # assignment-from-no-return
R1714, # consider-using-in
C0206, # consider-using-dict-items
W0221, # arguments-differ
R1711, # useless-return
R1720, # no-else-raise
R0205, # useless-object-inheritance
W3101, # missing-timeout
C0201, # consider-iterating-dictionary
R1719, # simplifiable-if-expression
W1201, # logging-not-lazy
W0707, # raise-missing-from
W0237, # arguments-renamed
E0606, # possibly-used-before-assignment
R1724, # no-else-continue
R1729, # use-a-generator
C0117, # unnecessary-negation
W0622, # redefined-builtin
W0212, # protected-access
R1728, # consider-using-generator
R1710, # inconsistent-return-statements
C1802, # use-implicit-booleaness-not-len
W0706, # try-except-raise
C1803, # use-implicit-booleaness-not-comparison
W0231, # super-init-not-called
C0123, # unidiomatic-typecheck
C0207, # use-maxsplit-arg
C2801, # unnecessary-dunder-call
E0203, # access-member-before-definition
E0611, # no-name-in-module
E0702, # raising-bad-type
E1101, # no-member
E1135, # unsupported-membership-test
R1703, # simplifiable-if-statement
R1718, # consider-using-set-comprehension
R1721, # unnecessary-comprehension
R1722, # consider-using-sys-exit
W0105, # pointless-string-statement
W0108, # unnecessary-lambda
W0222, # signature-differs
W0223, # abstract-method
W0246, # useless-parent-delegation
W0621, # redefined-outer-name
W0640, # cell-var-from-loop
W1509, # subprocess-popen-preexec-fn
W4701, # modified-iterating-list
2 changes: 1 addition & 1 deletion tests/report_tests/plugin_tests/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class JournalSizeLimitTest(StageTwoReportTest):
def pre_sos_setup(self):
# if the journal is already over our size limit, don't write anything
# new to it
from systemd import journal
from systemd import journal # pylint: disable=import-error
_reader = journal.Reader()
_size = _reader.get_usage() / 1024 / 1024
if _size > 20:
Expand Down
63 changes: 16 additions & 47 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,47 +7,49 @@ deps =
-r{toxinidir}/test-requirements.txt
python_magic
setenv =
PYTHONPATH = {toxinidir}/tests
PYTHONPATH = {toxinidir}/tests:{toxinidir}
avocado_cmd =
avocado run -p TESTLOCAL=true --max-parallel-tasks=1
stage_tests =
tests/cleaner_tests \
tests/collect_tests \
tests/report_tests \
tests/vendor_tests
{toxinidir}/tests/cleaner_tests \
{toxinidir}/tests/collect_tests \
{toxinidir}/tests/report_tests \
{toxinidir}/tests/vendor_tests
py_files =
setup.py plugins_overview.py sos tests
foreman_tests =
tests/product_tests/foreman
{toxinidir}/tests/product_tests/foreman

[testenv:flake8]
deps = flake8
commands = flake8
commands = flake8 {posargs:{[testenv]py_files}}

[testenv:pylint]
deps = pylint
commands = pylint --rcfile=tox.ini .
deps =
{[testenv]deps}
pylint
commands = pylint -v --rcfile={toxinidir}/pylintrc {posargs:{[testenv]py_files}}

[testenv:unit_tests]
basepython = python3
setenv =
PYTHONPATH = .
commands =
avocado run tests/unittests

[testenv:stageone_tests]
basepython = python3
commands =
{[testenv]avocado_cmd} -t stageone {posargs:[testenv]stage_tests}
{[testenv]avocado_cmd} -t stageone {posargs:{[testenv]stage_tests}}

[testenv:stagetwo_tests]
basepython = python3
sitepackages = True
commands =
{[testenv]avocado_cmd} -t stagetwo {posargs:[testenv]stage_tests}
{[testenv]avocado_cmd} -t stagetwo {posargs:{[testenv]stage_tests}}

[testenv:foreman_tests]
basepython = python3
commands =
{[testenv]avocado_cmd} -t foreman {posargs:[testenv]foreman_tests}
{[testenv]avocado_cmd} -t foreman {posargs:{[testenv]foreman_tests}}

[testenv:nosetests]
basepython = python3
Expand All @@ -56,36 +58,3 @@ deps =
nose3
commands =
nosetests -v --with-coverage --cover-package=sos tests/unittests --cover-html

[flake8]
exclude =
.git,
.tox,
debian,
docs

[pylint]
# C0114, # missing-module-docstring
# C0115, # missing-class-docstring
# C0116, # missing-function-docstring
# R0401, # cyclic-import
# R0801, # duplicate-code
# R0904, # too-many-public-methods
disable = all
enable =
C0209, # consider-using-f-string
C0411, # wrong-import-order
E1101, # no-member
R0912, # too-many-branches
R0914, # too-many-locals
R1725, # super-with-arguments
W1404, # implicit-str-concat
W4901, # deprecated-module
W4902, # deprecated-method
W4903 # deprecated-argument
max-line-length = 79
recursive = y
ignore =
.git,
.tox,
debian

0 comments on commit e89ccce

Please sign in to comment.