Skip to content

Start linting tests with black, isort and mypy and exclude old test files #1624

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
191 changes: 191 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,194 @@
# Build-system section
[build-system]
requires = ["setuptools>=40.8.0", "wheel"]
build-backend = "setuptools.build_meta"

# Black section
[tool.black]
force-exclude="""
(tests/aggregate_tests.py|
tests/fast_server_exit.py|
tests/simple_https_server.py|
tests/simple_server.py|
tests/slow_retrieval_server.py|
tests/utils.py|
tests/test_utils.py|
tests/test_repository_lib.py|
tests/test_arbitrary_package_attack.py|
tests/test_developer_tool.py|
tests/test_download.py|
tests/test_endless_data_attack.py|
tests/test_extraneous_dependencies_attack.py|
tests/test_formats.py|
tests/test_indefinite_freeze_attack.py|
tests/test_key_revocation_integration.py|
tests/test_keydb.py|
tests/test_log.py|
tests/test_mirrors.py|
tests/test_mix_and_match_attack.py|
tests/test_multiple_repositories_integration.py|
tests/test_repository_tool.py|
tests/test_replay_attack.py|
tests/test_roledb.py|
tests/test_root_versioning_integration.py|
tests/test_sig.py|
tests/test_slow_retrieval_attack.py|
tests/test_tutorial.py|
tests/test_unittest_toolbox.py|
tests/test_updater.py|
tests/test_updater_root_rotation_integration.py|
tests/repository_data/generate_project_data.py|
tests/repository_data/generate.py)"""

# isort section
[tool.isort]
skip = [
"tests/fast_server_exit.py",
"tests/simple_https_server.py",
"tests/simple_server.py",
"tests/slow_retrieval_server.py",
"tests/utils.py",
"tests/test_utils.py",
"tests/test_repository_lib.py",
"tests/test_arbitrary_package_attack.py",
"tests/test_developer_tool.py",
"tests/test_download.py",
"tests/test_endless_data_attack.py",
"tests/test_extraneous_dependencies_attack.py",
"tests/test_formats.py",
"tests/test_indefinite_freeze_attack.py",
"tests/test_key_revocation_integration.py",
"tests/test_keydb.py",
"tests/test_log.py",
"tests/test_mirrors.py",
"tests/test_mix_and_match_attack.py",
"tests/test_multiple_repositories_integration.py",
"tests/test_repository_tool.py",
"tests/test_replay_attack.py",
"tests/test_roledb.py",
"tests/test_root_versioning_integration.py",
"tests/test_sig.py",
"tests/test_slow_retrieval_attack.py",
"tests/test_tutorial.py",
"tests/test_unittest_toolbox.py",
"tests/test_updater.py",
"tests/test_updater_root_rotation_integration.py",
"tests/repository_data/generate_project_data.py",
"tests/repository_data/generate.py",
]

# Pylint section

# Minimal pylint configuration file for Secure Systems Lab Python Style Guide:
# https://github.com/secure-systems-lab/code-style-guidelines
#
# Based on Google Python Style Guide pylintrc and pylint defaults:
# https://google.github.io/styleguide/pylintrc
# http://pylint.pycqa.org/en/latest/technical_reference/features.html

[tool.pylint.master]
ignore = [
"aggregate_tests.py",
"fast_server_exit.py",
"simple_https_server.py",
"simple_server.py",
"slow_retrieval_server.py",
"utils.py",
"test_utils.py",
"test_repository_lib.py",
"test_arbitrary_package_attack.py",
"test_developer_tool.py",
"test_download.py",
"test_endless_data_attack.py",
"test_extraneous_dependencies_attack.py",
"test_formats.py",
"test_indefinite_freeze_attack.py",
"test_key_revocation_integration.py",
"test_keydb.py",
"test_log.py",
"test_mirrors.py",
"test_mix_and_match_attack.py",
"test_multiple_repositories_integration.py",
"test_repository_tool.py",
"test_replay_attack.py",
"test_roledb.py",
"test_root_versioning_integration.py",
"test_sig.py",
"test_slow_retrieval_attack.py",
"test_tutorial.py",
"test_unittest_toolbox.py",
"test_updater.py",
"test_updater_root_rotation_integration.py",
"generate_project_data.py",
"generate.py",
]

[tool.pylint.message_control]
# Disable the message, report, category or checker with the given id(s).
# NOTE: To keep this config as short as possible we only disable checks that
# are currently in conflict with our code. If new code displeases the linter
# (for good reasons) consider updating this config file, or disable checks with.
disable=[
"fixme",
"too-few-public-methods",
"too-many-arguments",
"duplicate-code"
]

[tool.pylint.basic]
good-names = ["i","j","k","v","e","f","fn","fp","_type","_"]
# Regexes for allowed names are copied from the Google pylintrc
# NOTE: Pylint captures regex name groups such as 'snake_case' or 'camel_case'.
# If there are multiple groups it enfoces the prevalent naming style inside
# each modules. Names in the exempt capturing group are ignored.
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_]*))$"""
ethod-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_]*))$"""
argument-rgx="""^[a-z][a-z0-9_]*$"""
attr-rgx="""^_{0,2}[a-z][a-z0-9_]*$"""
class-attribute-rgx="""^(_?[A-Z][A-Z0-9_]*|__[a-z0-9_]+__|_?[a-z][a-z0-9_]*)$"""
class-rgx="^_?[A-Z][a-zA-Z0-9]*$"
const-rgx="^(_?[A-Z][A-Z0-9_]*|__[a-z0-9_]+__|_?[a-z][a-z0-9_]*)$"
inlinevar-rgx="^[a-z][a-z0-9_]*$"
module-rgx="^(_?[a-z][a-z0-9_]*|__init__)$"
no-docstring-rgx="(__.*__|main|test.*|.*test|.*Test)$"
variable-rgx="^[a-z][a-z0-9_]*$"
docstring-min-length=10

[tool.pylint.format]
ignore-long-lines='(?x)(^\s*(\#\ )?<?https?://\S+>?$|^\s*(from\s+\S+\s+)?import\s+.+$)'
indent-string=" "
indent-after-paren=4
max-line-length=80
single-line-if-stmt="yes"

[tool.pylint.logging]
logging-format-style="old"

[tool.pylint.miscellaneous]
notes="TODO"

[tool.pylint.STRING]
check-quote-consistency="yes"

# mypy section
# Read more here: https://mypy.readthedocs.io/en/stable/config_file.html#using-a-pyproject-toml-file
[tool.mypy]
warn_unused_configs = "True"
warn_redundant_casts = "True"
warn_unused_ignores = "True"
warn_unreachable = "True"
strict_equality = "True"
disallow_untyped_defs = "True"
disallow_untyped_calls = "True"
files = [
"tuf/api/",
"tuf/ngclient",
"tuf/exceptions.py"
]

[[tool.mypy.overrides]]
module = [
"securesystemslib.*",
"urllib3.*"
]
ignore_missing_imports = "True"
18 changes: 0 additions & 18 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,3 @@ ignore =
.fossa.yml
.readthedocs.yaml

[mypy]
warn_unused_configs = True
warn_redundant_casts = True
warn_unused_ignores = True
warn_unreachable = True
strict_equality = True
disallow_untyped_defs = True
disallow_untyped_calls = True
files =
tuf/api/,
tuf/ngclient,
tuf/exceptions.py

[mypy-securesystemslib.*]
ignore_missing_imports = True

[mypy-urllib3.*]
ignore_missing_imports = True
Loading