mirror of
https://github.com/theupdateframework/python-tuf
synced 2026-05-24 10:08:28 +00:00
remove pylint and suppressed inline errors from pylint
Signed-off-by: E3E <ntanzill@purdue.edu>
This commit is contained in:
parent
da38b473bd
commit
f156e21537
24 changed files with 3 additions and 88 deletions
1
.github/dependabot.yml
vendored
1
.github/dependabot.yml
vendored
|
|
@ -18,7 +18,6 @@ updates:
|
|||
- "bandit"
|
||||
- "coverage"
|
||||
- "mypy"
|
||||
- "pylint"
|
||||
- "ruff"
|
||||
- "tox"
|
||||
dependencies:
|
||||
|
|
|
|||
|
|
@ -62,7 +62,6 @@ def open(self, role: str) -> Metadata:
|
|||
|
||||
# if there is a metadata version fetched from remote, use that
|
||||
# HACK: access Updater internals
|
||||
# pylint: disable=protected-access
|
||||
if role in self.updater._trusted_set:
|
||||
return copy.deepcopy(self.updater._trusted_set[role])
|
||||
|
||||
|
|
@ -105,7 +104,7 @@ def add_target(self, role: str, targetpath: str) -> bool:
|
|||
with self.edit_targets(role) as delegated:
|
||||
delegated.targets[targetpath] = targetfile
|
||||
|
||||
except Exception as e: # pylint: disable=broad-except
|
||||
except Exception as e:
|
||||
print(f"Failed to submit new {role} with added target: {e}")
|
||||
return False
|
||||
|
||||
|
|
|
|||
|
|
@ -95,56 +95,6 @@ ignore = ["D400","D415","D213","D205","D202","D107","D407","D413","D212","D104",
|
|||
"tests/*" = ["D", "E"]
|
||||
"examples/*/*" = ["D"]
|
||||
|
||||
# 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.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",
|
||||
"format",
|
||||
"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_]*))$"
|
||||
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_]*))$"
|
||||
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.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]
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
# Lint tools
|
||||
# (We are not so interested in the specific versions of the tools: the versions
|
||||
# are pinned to prevent unexpected linting failures when tools update)
|
||||
pylint==3.0.3
|
||||
ruff==0.2.1
|
||||
mypy==1.8.0
|
||||
bandit==1.7.7
|
||||
|
|
|
|||
|
|
@ -99,7 +99,6 @@ class RepositoryTarget:
|
|||
class RepositorySimulator(FetcherInterface):
|
||||
"""Simulates a repository that can be used for testing."""
|
||||
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
def __init__(self) -> None:
|
||||
self.md_delegates: Dict[str, Metadata[Targets]] = {}
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,6 @@
|
|||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# pylint: disable=too-many-public-methods,too-many-statements
|
||||
class TestMetadata(unittest.TestCase):
|
||||
"""Tests for public API of all classes in 'tuf/api/metadata.py'."""
|
||||
|
||||
|
|
@ -246,7 +245,7 @@ def test_sign_failures(self) -> None:
|
|||
os.path.join(self.repo_dir, "metadata", "snapshot.json")
|
||||
)
|
||||
|
||||
class FailingSigner(Signer): # pylint: disable=missing-class-docstring
|
||||
class FailingSigner(Signer):
|
||||
@classmethod
|
||||
def from_priv_key_uri(
|
||||
cls,
|
||||
|
|
@ -365,7 +364,6 @@ def test_metadata_verify_delegate(self) -> None:
|
|||
role2.verify_delegate("role1", role1)
|
||||
|
||||
def test_signed_verify_delegate(self) -> None:
|
||||
# pylint: disable=too-many-locals,too-many-statements
|
||||
root_path = os.path.join(self.repo_dir, "metadata", "root.json")
|
||||
root_md = Metadata[Root].from_file(root_path)
|
||||
root = root_md.signed
|
||||
|
|
@ -742,7 +740,6 @@ def test_root_add_key_and_revoke_key(self) -> None:
|
|||
root.signed.revoke_key(keyid, "nosuchrole")
|
||||
|
||||
def test_is_target_in_pathpattern(self) -> None:
|
||||
# pylint: disable=protected-access
|
||||
supported_use_cases = [
|
||||
("foo.tgz", "foo.tgz"),
|
||||
("foo.tgz", "*"),
|
||||
|
|
|
|||
|
|
@ -53,7 +53,6 @@ def _run_script_and_assert_files(
|
|||
CWD."""
|
||||
script_path = str(self.repo_examples_dir / script_name)
|
||||
with open(script_path, "rb") as f:
|
||||
# pylint: disable=exec-used
|
||||
exec(
|
||||
compile(f.read(), script_path, "exec"),
|
||||
{"__file__": script_path},
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ def setUpClass(cls) -> None:
|
|||
|
||||
@utils.run_sub_tests_with_dataset(classes_attributes_modifications)
|
||||
def test_classes_eq_(self, test_case_data: Dict[str, Any]) -> None:
|
||||
obj = self.objects[self.case_name] # pylint: disable=no-member
|
||||
obj = self.objects[self.case_name]
|
||||
|
||||
# Assert that obj is not equal to an object from another type
|
||||
self.assertNotEqual(obj, "")
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@
|
|||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# pylint: disable=too-many-public-methods
|
||||
class TestSerialization(unittest.TestCase):
|
||||
"""Test serialization for all classes in 'tuf/api/metadata.py'."""
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@
|
|||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# pylint: disable=too-many-public-methods
|
||||
class TestTrustedMetadataSet(unittest.TestCase):
|
||||
"""Tests for all public API of the TrustedMetadataSet class."""
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ class TestConsistentSnapshot(unittest.TestCase):
|
|||
dump_dir: Optional[str] = None
|
||||
|
||||
def setUp(self) -> None:
|
||||
# pylint: disable=consider-using-with
|
||||
self.subtest_count = 0
|
||||
self.temp_dir = tempfile.TemporaryDirectory()
|
||||
self.metadata_dir = os.path.join(self.temp_dir.name, "metadata")
|
||||
|
|
|
|||
|
|
@ -67,7 +67,6 @@ class TestDelegations(unittest.TestCase):
|
|||
dump_dir: Optional[str] = None
|
||||
|
||||
def setUp(self) -> None:
|
||||
# pylint: disable=consider-using-with
|
||||
self.subtest_count = 0
|
||||
self.temp_dir = tempfile.TemporaryDirectory()
|
||||
self.metadata_dir = os.path.join(self.temp_dir.name, "metadata")
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ class TestFetchTarget(unittest.TestCase):
|
|||
dump_dir: Optional[str] = None
|
||||
|
||||
def setUp(self) -> None:
|
||||
# pylint: disable-next=consider-using-with
|
||||
self.temp_dir = tempfile.TemporaryDirectory()
|
||||
self.metadata_dir = os.path.join(self.temp_dir.name, "metadata")
|
||||
self.targets_dir = os.path.join(self.temp_dir.name, "targets")
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ class TestUpdaterKeyRotations(unittest.TestCase):
|
|||
|
||||
@classmethod
|
||||
def setUpClass(cls) -> None:
|
||||
# pylint: disable-next=consider-using-with
|
||||
cls.temp_dir = tempfile.TemporaryDirectory()
|
||||
|
||||
# Pre-create a bunch of keys and signers
|
||||
|
|
@ -58,14 +57,12 @@ def tearDownClass(cls) -> None:
|
|||
|
||||
def setup_subtest(self) -> None:
|
||||
# Setup repository for subtest: make sure no roots have been published
|
||||
# pylint: disable=attribute-defined-outside-init
|
||||
self.sim = RepositorySimulator()
|
||||
self.sim.signed_roots.clear()
|
||||
self.sim.root.version = 0
|
||||
|
||||
if self.dump_dir is not None:
|
||||
# create subtest dumpdir
|
||||
# pylint: disable=no-member
|
||||
name = f"{self.id().split('.')[-1]}-{self.case_name}"
|
||||
self.sim.dump_dir = os.path.join(self.dump_dir, name)
|
||||
os.mkdir(self.sim.dump_dir)
|
||||
|
|
@ -76,7 +73,6 @@ def _run_refresh(self) -> None:
|
|||
self.sim.write()
|
||||
|
||||
# bootstrap with initial root
|
||||
# pylint: disable=attribute-defined-outside-init
|
||||
self.metadata_dir = tempfile.mkdtemp(dir=self.temp_dir.name)
|
||||
with open(os.path.join(self.metadata_dir, "root.json"), "bw") as f:
|
||||
f.write(self.sim.signed_roots[0])
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@
|
|||
class TestUpdater(unittest.TestCase):
|
||||
"""Test the Updater class from 'tuf/ngclient/updater.py'."""
|
||||
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
server_process_handler: ClassVar[utils.TestServerProcess]
|
||||
|
||||
@classmethod
|
||||
|
|
@ -282,7 +281,6 @@ def test_length_hash_mismatch(self) -> None:
|
|||
targetinfo.hashes = {"sha256": "abcd"}
|
||||
self.updater.download_target(targetinfo)
|
||||
|
||||
# pylint: disable=protected-access
|
||||
def test_updating_root(self) -> None:
|
||||
# Bump root version, resign and refresh
|
||||
self._modify_repository_root(lambda root: None, bump_version=True)
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@
|
|||
from tuf.ngclient import Updater
|
||||
|
||||
|
||||
# pylint: disable=too-many-public-methods
|
||||
class TestRefresh(unittest.TestCase):
|
||||
"""Test update of top-level metadata following
|
||||
'Detailed client workflow' in the specification."""
|
||||
|
|
@ -49,7 +48,6 @@ class TestRefresh(unittest.TestCase):
|
|||
) - datetime.timedelta(days=5)
|
||||
|
||||
def setUp(self) -> None:
|
||||
# pylint: disable=consider-using-with
|
||||
self.temp_dir = tempfile.TemporaryDirectory()
|
||||
self.metadata_dir = os.path.join(self.temp_dir.name, "metadata")
|
||||
self.targets_dir = os.path.join(self.temp_dir.name, "targets")
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ class TestUpdater(unittest.TestCase):
|
|||
"""Test ngclient Updater input validation."""
|
||||
|
||||
def setUp(self) -> None:
|
||||
# pylint: disable-next=consider-using-with
|
||||
self.temp_dir = tempfile.TemporaryDirectory()
|
||||
self.metadata_dir = os.path.join(self.temp_dir.name, "metadata")
|
||||
self.targets_dir = os.path.join(self.temp_dir.name, "targets")
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ def can_connect(port: int) -> bool:
|
|||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
sock.connect(("localhost", port))
|
||||
return True
|
||||
# pylint: disable=broad-except
|
||||
except Exception:
|
||||
return False
|
||||
finally:
|
||||
|
|
|
|||
|
|
@ -230,7 +230,6 @@ def _start_process(self, extra_cmd_args: List[str], popen_cwd: str) -> None:
|
|||
|
||||
# Reusing one subprocess in multiple tests, but split up the logs
|
||||
# for each.
|
||||
# pylint: disable=consider-using-with
|
||||
self.__server_process = subprocess.Popen(
|
||||
command,
|
||||
stdout=subprocess.PIPE,
|
||||
|
|
@ -362,5 +361,4 @@ def clean(self) -> None:
|
|||
|
||||
def is_process_running(self) -> bool:
|
||||
assert isinstance(self.__server_process, subprocess.Popen)
|
||||
# pylint: disable=simplifiable-if-expression
|
||||
return True if self.__server_process.poll() is None else False
|
||||
|
|
|
|||
1
tox.ini
1
tox.ini
|
|
@ -49,7 +49,6 @@ lint_dirs = tuf examples tests verify_release
|
|||
commands =
|
||||
ruff check {[testenv:lint]lint_dirs}
|
||||
ruff format --diff {[testenv:lint]lint_dirs}
|
||||
pylint -j 0 --rcfile=pyproject.toml {[testenv:lint]lint_dirs}
|
||||
|
||||
mypy {[testenv:lint]lint_dirs}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
#### Repository errors ####
|
||||
|
||||
# pylint: disable=unused-import
|
||||
from securesystemslib.exceptions import StorageError # noqa: F401
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,6 @@
|
|||
_TARGETS = "targets"
|
||||
_TIMESTAMP = "timestamp"
|
||||
|
||||
# pylint: disable=too-many-lines
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
@ -157,7 +156,6 @@ def signed_bytes(self) -> bytes:
|
|||
"""Default canonical json byte representation of ``self.signed``."""
|
||||
|
||||
# Use local scope import to avoid circular import errors
|
||||
# pylint: disable=import-outside-toplevel
|
||||
from tuf.api.serialization.json import CanonicalJSONSerializer
|
||||
|
||||
return CanonicalJSONSerializer().serialize(self.signed)
|
||||
|
|
@ -267,7 +265,6 @@ def from_bytes(
|
|||
|
||||
if deserializer is None:
|
||||
# Use local scope import to avoid circular import errors
|
||||
# pylint: disable=import-outside-toplevel
|
||||
from tuf.api.serialization.json import JSONDeserializer
|
||||
|
||||
deserializer = JSONDeserializer()
|
||||
|
|
@ -297,7 +294,6 @@ def to_bytes(
|
|||
|
||||
if serializer is None:
|
||||
# Use local scope import to avoid circular import errors
|
||||
# pylint: disable=import-outside-toplevel
|
||||
from tuf.api.serialization.json import JSONSerializer
|
||||
|
||||
serializer = JSONSerializer(compact=True)
|
||||
|
|
@ -855,7 +851,6 @@ class Root(Signed, _DelegatorMixin):
|
|||
|
||||
type = _ROOT
|
||||
|
||||
# pylint: disable=too-many-arguments
|
||||
def __init__(
|
||||
self,
|
||||
version: Optional[int] = None,
|
||||
|
|
@ -2001,7 +1996,6 @@ class Targets(Signed, _DelegatorMixin):
|
|||
|
||||
type = _TARGETS
|
||||
|
||||
# pylint: disable=too-many-arguments
|
||||
def __init__(
|
||||
self,
|
||||
version: Optional[int] = None,
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
from tuf.api.exceptions import RepositoryError
|
||||
|
||||
if TYPE_CHECKING:
|
||||
# pylint: disable=cyclic-import
|
||||
from tuf.api.metadata import Metadata, Signed
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@
|
|||
|
||||
from securesystemslib.formats import encode_canonical
|
||||
|
||||
# pylint: disable=cyclic-import
|
||||
# ... to allow de/serializing Metadata and Signed objects here, while also
|
||||
# creating default de/serializers there (see metadata local scope imports).
|
||||
# NOTE: A less desirable alternative would be to add more abstraction layers.
|
||||
|
|
|
|||
Loading…
Reference in a new issue