Skip to content

Commit d991362

Browse files
author
Jussi Kukkonen
authored
Merge pull request #1699 from MVrachev/move-configs
Move linters configurations in pyproject.toml
2 parents 171f9ee + 5c8a866 commit d991362

File tree

6 files changed

+93
-74
lines changed

6 files changed

+93
-74
lines changed

docs/CONTRIBUTORS.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,8 @@ CI/CD will check that new TUF code is formatted with `black
113113
Auto-formatting can be done on the command line:
114114
::
115115

116-
$ # TODO: configure black and isort args in pyproject.toml (see #1161)
117-
$ black --line-length 80 tuf/api
118-
$ isort --line-length 80 --profile black -p tuf tuf/api
116+
$ black <filename>
117+
$ isort <filename>
119118

120119
or via source code editor plugin
121120
[`black <https://black.readthedocs.io/en/stable/editor_integration.html>`__,

pyproject.toml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,90 @@
1+
# Build-system section
12
[build-system]
23
requires = ["setuptools>=40.8.0", "wheel"]
34
build-backend = "setuptools.build_meta"
5+
6+
# Black section
7+
# Read more here: https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html#configuration-via-a-file
8+
[tool.black]
9+
line-length=80
10+
11+
# Isort section
12+
# Read more here: https://pycqa.github.io/isort/docs/configuration/config_files.html
13+
[tool.isort]
14+
profile="black"
15+
line_length=80
16+
known_first_party = ["tuf"]
17+
18+
# Pylint section
19+
20+
# Minimal pylint configuration file for Secure Systems Lab Python Style Guide:
21+
# https://github.com/secure-systems-lab/code-style-guidelines
22+
#
23+
# Based on Google Python Style Guide pylintrc and pylint defaults:
24+
# https://google.github.io/styleguide/pylintrc
25+
# http://pylint.pycqa.org/en/latest/technical_reference/features.html
26+
27+
[tool.pylint.message_control]
28+
# Disable the message, report, category or checker with the given id(s).
29+
# NOTE: To keep this config as short as possible we only disable checks that
30+
# are currently in conflict with our code. If new code displeases the linter
31+
# (for good reasons) consider updating this config file, or disable checks with.
32+
disable=[
33+
"fixme",
34+
"too-few-public-methods",
35+
"too-many-arguments",
36+
"format",
37+
"duplicate-code"
38+
]
39+
40+
[tool.pylint.basic]
41+
good-names = ["i","j","k","v","e","f","fn","fp","_type","_"]
42+
# Regexes for allowed names are copied from the Google pylintrc
43+
# NOTE: Pylint captures regex name groups such as 'snake_case' or 'camel_case'.
44+
# If there are multiple groups it enfoces the prevalent naming style inside
45+
# each modules. Names in the exempt capturing group are ignored.
46+
function-rgx="^(?:(?P<exempt>setUp|tearDown|setUpModule|tearDownModule)|(?P<camel_case>_?[A-Z][a-zA-Z0-9]*)|(?P<snake_case>_?[a-z][a-z0-9_]*))$"
47+
method-rgx="(?x)^(?:(?P<exempt>_[a-z0-9_]+__|runTest|setUp|tearDown|setUpTestCase|tearDownTestCase|setupSelf|tearDownClass|setUpClass|(test|assert)_*[A-Z0-9][a-zA-Z0-9_]*|next)|(?P<camel_case>_{0,2}[A-Z][a-zA-Z0-9_]*)|(?P<snake_case>_{0,2}[a-z][a-z0-9_]*))$"
48+
argument-rgx="^[a-z][a-z0-9_]*$"
49+
attr-rgx="^_{0,2}[a-z][a-z0-9_]*$"
50+
class-attribute-rgx="^(_?[A-Z][A-Z0-9_]*|__[a-z0-9_]+__|_?[a-z][a-z0-9_]*)$"
51+
class-rgx="^_?[A-Z][a-zA-Z0-9]*$"
52+
const-rgx="^(_?[A-Z][A-Z0-9_]*|__[a-z0-9_]+__|_?[a-z][a-z0-9_]*)$"
53+
inlinevar-rgx="^[a-z][a-z0-9_]*$"
54+
module-rgx="^(_?[a-z][a-z0-9_]*|__init__)$"
55+
no-docstring-rgx="(__.*__|main|test.*|.*test|.*Test)$"
56+
variable-rgx="^[a-z][a-z0-9_]*$"
57+
docstring-min-length=10
58+
59+
[tool.pylint.logging]
60+
logging-format-style="old"
61+
62+
[tool.pylint.miscellaneous]
63+
notes="TODO"
64+
65+
[tool.pylint.STRING]
66+
check-quote-consistency="yes"
67+
68+
# mypy section
69+
# Read more here: https://mypy.readthedocs.io/en/stable/config_file.html#using-a-pyproject-toml-file
70+
[tool.mypy]
71+
warn_unused_configs = "True"
72+
warn_redundant_casts = "True"
73+
warn_unused_ignores = "True"
74+
warn_unreachable = "True"
75+
strict_equality = "True"
76+
disallow_untyped_defs = "True"
77+
disallow_untyped_calls = "True"
78+
show_error_codes = "True"
79+
files = [
80+
"tuf/api/",
81+
"tuf/ngclient",
82+
"tuf/exceptions.py"
83+
]
84+
85+
[[tool.mypy.overrides]]
86+
module = [
87+
"securesystemslib.*",
88+
"urllib3.*"
89+
]
90+
ignore_missing_imports = "True"

setup.cfg

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -52,23 +52,3 @@ tuf = py.typed
5252
ignore =
5353
.fossa.yml
5454
.readthedocs.yaml
55-
56-
[mypy]
57-
warn_unused_configs = True
58-
warn_redundant_casts = True
59-
warn_unused_ignores = True
60-
warn_unreachable = True
61-
strict_equality = True
62-
disallow_untyped_defs = True
63-
disallow_untyped_calls = True
64-
show_error_codes = True
65-
files =
66-
tuf/api/,
67-
tuf/ngclient,
68-
tuf/exceptions.py
69-
70-
[mypy-securesystemslib.*]
71-
ignore_missing_imports = True
72-
73-
[mypy-urllib3.*]
74-
ignore_missing_imports = True

tox.ini

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,9 @@ commands =
4040
changedir = {toxinidir}
4141
commands =
4242
# Use different configs for new (tuf/api/*) and legacy code
43-
# TODO: configure black and isort args in pyproject.toml (see #1161)
44-
black --check --diff --line-length 80 tuf/api tuf/ngclient
45-
isort --check --diff --line-length 80 --profile black -p tuf tuf/api tuf/ngclient
46-
pylint -j 0 tuf/api tuf/ngclient --rcfile=tuf/api/pylintrc
43+
black --check --diff tuf/api tuf/ngclient
44+
isort --check --diff tuf/api tuf/ngclient
45+
pylint -j 0 tuf/api tuf/ngclient --rcfile=pyproject.toml
4746

4847
# NOTE: Contrary to what the pylint docs suggest, ignoring full paths does
4948
# work, unfortunately each subdirectory has to be ignored explicitly.

tuf/api/metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ def __init__(
539539
):
540540
if not all(
541541
isinstance(at, str) for at in [keyid, keytype, scheme]
542-
) or not isinstance(keyval, Dict):
542+
) or not isinstance(keyval, dict):
543543
raise TypeError("Unexpected Key attributes types!")
544544
self.keyid = keyid
545545
self.keytype = keytype

tuf/api/pylintrc

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)