Skip to content

Commit cb086ea

Browse files
Lion HollerLion Holler
Lion Holler
authored and
Lion Holler
committed
inline comments removed, requirements-lint.txt updated, dependabot updated, E501 suppressed, mypy.ini file list removed
1 parent 04b0fcd commit cb086ea

22 files changed

+80
-204
lines changed

.github/dependabot.yml

+1-4
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,9 @@ updates:
1414
test-and-lint-dependencies:
1515
# Python dependencies that are only pinned to ensure test reproducibility
1616
patterns:
17-
- "bandit"
18-
- "black"
17+
- "ruff"
1918
- "coverage"
20-
- "isort"
2119
- "mypy"
22-
- "pylint"
2320
dependencies:
2421
# Python (developer) runtime dependencies. Also any new dependencies not
2522
# caught by earlier groups

mypy.ini

-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
[mypy]
22
warn_unused_configs = True
3-
files =
4-
securesystemslib/signer/*.py,
5-
securesystemslib/storage.py,
6-
securesystemslib/_gpg/constants.py
73

84
exclude = securesystemslib/_vendor
95

pylintrc

-54
This file was deleted.

pyproject.toml

+10-18
Original file line numberDiff line numberDiff line change
@@ -73,31 +73,23 @@ include = [
7373
# Ruff section
7474
[tool.ruff]
7575
lint.select = [
76-
"I", # isort: all
77-
"PL", # pylint: all
78-
"S", # flake8-bandit: all
79-
"N", # pep8-naming: all
80-
"RUF100" # ruff: find unused noqa
76+
"E", # ruff default
77+
"F", # ruff default
78+
"I", # isort: all
79+
"PL", # pylint: all
80+
"S", # flake8-bandit: all
81+
"N", # pep8-naming: all
82+
"RUF100" # ruff: find unused noqa
83+
]
84+
lint.ignore = [
85+
"E501" # ignore line-too-long
8186
]
8287
exclude = ["_vendor"]
8388

8489
# Same as Black.
8590
line-length = 80
8691
indent-width = 4
8792

88-
[tool.ruff.format]
89-
# Like Black, use double quotes for strings.
90-
quote-style = "double"
91-
92-
# Like Black, indent with spaces, rather than tabs.
93-
indent-style = "space"
94-
95-
# Like Black, respect magic trailing commas.
96-
skip-magic-trailing-comma = false
97-
98-
# Like Black, automatically detect the appropriate line ending.
99-
line-ending = "auto"
100-
10193
[tool.ruff.lint.per-file-ignores]
10294
"tests/*" = [
10395
"S", # bandit: Not running bandit on tests

requirements-lint.txt

-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
11
mypy==1.10.0
2-
black==24.4.2
3-
isort==5.13.2
4-
pylint==3.2.3
5-
bandit==1.7.9
62
ruff==0.4.10

securesystemslib/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# pylint: disable=missing-module-docstring
21
import logging
32

43
__version__ = "1.1.0"

securesystemslib/_gpg/common.py

+25-26
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def parse_pubkey_payload(data):
105105
ptr += 1
106106
if version_number not in SUPPORTED_PUBKEY_PACKET_VERSIONS:
107107
raise PacketVersionNotSupportedError(
108-
"Pubkey packet version '{}' not supported, must be one of {}".format( # pylint: disable=consider-using-f-string
108+
"Pubkey packet version '{}' not supported, must be one of {}".format(
109109
version_number, SUPPORTED_PUBKEY_PACKET_VERSIONS
110110
)
111111
)
@@ -130,7 +130,7 @@ def parse_pubkey_payload(data):
130130
# as described in section 5.2.3.21.
131131
if algorithm not in SUPPORTED_SIGNATURE_ALGORITHMS:
132132
raise SignatureAlgorithmNotSupportedError(
133-
"Signature algorithm '{}' not " # pylint: disable=consider-using-f-string
133+
"Signature algorithm '{}' not "
134134
"supported, please verify that your gpg configuration is creating "
135135
"either DSA, RSA, or EdDSA signatures (see RFC4880 9.1. Public-Key "
136136
"Algorithms).".format(algorithm)
@@ -216,7 +216,7 @@ def parse_pubkey_bundle(data):
216216
and not key_bundle[PACKET_TYPE_PRIMARY_KEY]["key"]
217217
):
218218
raise PacketParsingError(
219-
"First packet must be a primary key ('{}'), " # pylint: disable=consider-using-f-string
219+
"First packet must be a primary key ('{}'), "
220220
"got '{}'.".format(PACKET_TYPE_PRIMARY_KEY, packet_type)
221221
)
222222

@@ -282,7 +282,7 @@ def parse_pubkey_bundle(data):
282282

283283
else:
284284
log.info(
285-
"Ignoring gpg key packet '{}', we only handle packets of " # pylint: disable=logging-format-interpolation,consider-using-f-string
285+
"Ignoring gpg key packet '{}', we only handle packets of "
286286
"types '{}' (see RFC4880 4.3. Packet Tags).".format(
287287
packet_type,
288288
[
@@ -297,8 +297,8 @@ def parse_pubkey_bundle(data):
297297

298298
# Both errors might be raised in parse_packet_header and in this loop
299299
except (PacketParsingError, IndexError) as e:
300-
raise PacketParsingError( # pylint: disable=raise-missing-from
301-
"Invalid public key data at position {}: {}.".format( # pylint: disable=consider-using-f-string
300+
raise PacketParsingError(
301+
"Invalid public key data at position {}: {}.".format(
302302
position, e
303303
)
304304
)
@@ -369,15 +369,15 @@ def _assign_certified_key_info(bundle):
369369
# TODO: Revise exception taxonomy:
370370
# It's okay to ignore some exceptions (unsupported algorithms etc.) but
371371
# we should blow up if a signature is malformed (missing subpackets).
372-
except Exception as e: # pylint: disable=broad-except
372+
except Exception as e:
373373
log.info(e)
374374
continue
375375

376376
if not bundle[PACKET_TYPE_PRIMARY_KEY]["key"]["keyid"].endswith(
377377
signature["keyid"]
378378
):
379379
log.info(
380-
"Ignoring User ID certificate issued by '{}'.".format( # pylint: disable=logging-format-interpolation,consider-using-f-string
380+
"Ignoring User ID certificate issued by '{}'.".format(
381381
signature["keyid"]
382382
)
383383
)
@@ -392,7 +392,7 @@ def _assign_certified_key_info(bundle):
392392

393393
if not is_valid:
394394
log.info(
395-
"Ignoring invalid User ID self-certificate issued " # pylint: disable=logging-format-interpolation,consider-using-f-string
395+
"Ignoring invalid User ID self-certificate issued "
396396
"by '{}'.".format(signature["keyid"])
397397
)
398398
continue
@@ -493,7 +493,7 @@ def _get_verified_subkeys(bundle):
493493
)
494494

495495
# TODO: Revise exception taxonomy
496-
except Exception as e: # pylint: disable=broad-except
496+
except Exception as e:
497497
log.info(e)
498498
continue
499499

@@ -523,7 +523,7 @@ def _get_verified_subkeys(bundle):
523523
key_binding_signatures.append(signature)
524524

525525
# TODO: Revise exception taxonomy
526-
except Exception as e: # pylint: disable=broad-except
526+
except Exception as e:
527527
log.info(e)
528528
continue
529529
# NOTE: As per the V4 key structure diagram in RFC4880 section 12.1., a
@@ -535,7 +535,7 @@ def _get_verified_subkeys(bundle):
535535
# an *embedded primary key binding signature*.
536536
if len(key_binding_signatures) != 1:
537537
log.info(
538-
"Ignoring subkey '{}' due to wrong amount of key binding " # pylint: disable=logging-format-interpolation,consider-using-f-string
538+
"Ignoring subkey '{}' due to wrong amount of key binding "
539539
"signatures ({}), must be exactly 1.".format(
540540
subkey["keyid"], len(key_binding_signatures)
541541
)
@@ -550,7 +550,7 @@ def _get_verified_subkeys(bundle):
550550

551551
if not is_valid:
552552
log.info(
553-
"Ignoring subkey '{}' due to invalid key binding signature.".format( # pylint: disable=logging-format-interpolation,consider-using-f-string
553+
"Ignoring subkey '{}' due to invalid key binding signature.".format(
554554
subkey["keyid"]
555555
)
556556
)
@@ -610,8 +610,9 @@ def get_pubkey_bundle(data, keyid):
610610
"""
611611
if not data:
612612
raise KeyNotFoundError(
613-
"Could not find gpg key '{}' in empty exported key " # pylint: disable=consider-using-f-string
614-
"data.".format(keyid)
613+
"Could not find gpg key '{}' in empty exported key " "data.".format(
614+
keyid
615+
)
615616
)
616617

617618
# Parse out master key and subkeys (enriched and verified via certificates
@@ -631,7 +632,7 @@ def get_pubkey_bundle(data, keyid):
631632
if public_key and public_key["keyid"].endswith(keyid.lower()):
632633
if idx > 1:
633634
log.debug(
634-
"Exporting master key '{}' including subkeys '{}' for" # pylint: disable=logging-format-interpolation,consider-using-f-string
635+
"Exporting master key '{}' including subkeys '{}' for"
635636
" passed keyid '{}'.".format(
636637
master_public_key["keyid"],
637638
", ".join(list(sub_public_keys.keys())),
@@ -642,9 +643,7 @@ def get_pubkey_bundle(data, keyid):
642643

643644
else:
644645
raise KeyNotFoundError(
645-
"Could not find gpg key '{}' in exported key data.".format( # pylint: disable=consider-using-f-string
646-
keyid
647-
)
646+
"Could not find gpg key '{}' in exported key data.".format(keyid)
648647
)
649648

650649
# Add subkeys dictionary to master pubkey "subkeys" field if subkeys exist
@@ -655,7 +654,7 @@ def get_pubkey_bundle(data, keyid):
655654

656655

657656
# ruff: noqa: PLR0912, PLR0915
658-
def parse_signature_packet( # pylint: disable=too-many-locals,too-many-branches,too-many-statements
657+
def parse_signature_packet(
659658
data,
660659
supported_signature_types=None,
661660
supported_hash_algorithms=None,
@@ -725,7 +724,7 @@ def parse_signature_packet( # pylint: disable=too-many-locals,too-many-branches
725724
ptr += 1
726725
if version_number not in SUPPORTED_SIGNATURE_PACKET_VERSIONS:
727726
raise ValueError(
728-
"Signature version '{}' not supported, must be one of " # pylint: disable=consider-using-f-string
727+
"Signature version '{}' not supported, must be one of "
729728
"{}.".format(version_number, SUPPORTED_SIGNATURE_PACKET_VERSIONS)
730729
)
731730

@@ -738,7 +737,7 @@ def parse_signature_packet( # pylint: disable=too-many-locals,too-many-branches
738737

739738
if signature_type not in supported_signature_types:
740739
raise ValueError(
741-
"Signature type '{}' not supported, must be one of {} " # pylint: disable=consider-using-f-string
740+
"Signature type '{}' not supported, must be one of {} "
742741
"(see RFC4880 5.2.1. Signature Types).".format(
743742
signature_type, supported_signature_types
744743
)
@@ -749,7 +748,7 @@ def parse_signature_packet( # pylint: disable=too-many-locals,too-many-branches
749748

750749
if signature_algorithm not in SUPPORTED_SIGNATURE_ALGORITHMS:
751750
raise ValueError(
752-
"Signature algorithm '{}' not " # pylint: disable=consider-using-f-string
751+
"Signature algorithm '{}' not "
753752
"supported, please verify that your gpg configuration is creating "
754753
"either DSA, RSA, or EdDSA signatures (see RFC4880 9.1. Public-Key "
755754
"Algorithms).".format(signature_algorithm)
@@ -763,7 +762,7 @@ def parse_signature_packet( # pylint: disable=too-many-locals,too-many-branches
763762

764763
if hash_algorithm not in supported_hash_algorithms:
765764
raise ValueError(
766-
"Hash algorithm '{}' not supported, must be one of {}" # pylint: disable=consider-using-f-string
765+
"Hash algorithm '{}' not supported, must be one of {}"
767766
" (see RFC4880 9.4. Hash Algorithms).".format(
768767
hash_algorithm, supported_hash_algorithms
769768
)
@@ -863,7 +862,7 @@ def parse_signature_packet( # pylint: disable=too-many-locals,too-many-branches
863862
# Fail if keyid and short keyid are specified but don't match
864863
if keyid and not keyid.endswith(short_keyid): # pragma: no cover
865864
raise ValueError(
866-
"This signature packet seems to be corrupted. The key ID " # pylint: disable=consider-using-f-string
865+
"This signature packet seems to be corrupted. The key ID "
867866
"'{}' of the 'Issuer' subpacket must match the lower 64 bits of the "
868867
"fingerprint '{}' of the 'Issuer Fingerprint' subpacket (see RFC4880 "
869868
"and rfc4880bis-06 5.2.3.28. Issuer Fingerprint).".format(
@@ -887,7 +886,7 @@ def parse_signature_packet( # pylint: disable=too-many-locals,too-many-branches
887886
signature = handler.get_signature_params(data[ptr:])
888887

889888
signature_data = {
890-
"keyid": "{}".format(keyid), # pylint: disable=consider-using-f-string
889+
"keyid": "{}".format(keyid),
891890
"other_headers": binascii.hexlify(data[:other_headers_ptr]).decode(
892891
"ascii"
893892
),

securesystemslib/_gpg/constants.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import logging
2121
import os
2222
import shlex
23-
import subprocess # nosec
23+
import subprocess
2424
from typing import List, Optional
2525

2626
log = logging.getLogger(__name__)
@@ -36,7 +36,7 @@ def is_available_gnupg(gnupg: str, timeout: Optional[int] = None) -> bool:
3636

3737
gpg_version_cmd = shlex.split(f"{gnupg} --version")
3838
try:
39-
subprocess.run( # nosec
39+
subprocess.run(
4040
gpg_version_cmd, # noqa: S603
4141
capture_output=True,
4242
timeout=timeout,

securesystemslib/_gpg/dsa.py

-3
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,11 @@
2727
except ImportError:
2828
CRYPTO = False
2929

30-
# pylint: disable=wrong-import-position
3130
# ruff: noqa: E402
3231
from securesystemslib import exceptions
3332
from securesystemslib._gpg import util as gpg_util
3433
from securesystemslib._gpg.exceptions import PacketParsingError
3534

36-
# pylint: enable=wrong-import-position
37-
3835

3936
def create_pubkey(pubkey_info):
4037
"""

securesystemslib/_gpg/eddsa.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def get_pubkey_params(data):
7979
# See 9.2. ECC Curve OID
8080
if curve_oid != ED25519_PUBLIC_KEY_OID:
8181
raise PacketParsingError(
82-
"bad ed25519 curve OID '{}', expected {}'".format( # pylint: disable=consider-using-f-string
82+
"bad ed25519 curve OID '{}', expected {}'".format(
8383
curve_oid, ED25519_PUBLIC_KEY_OID
8484
)
8585
)
@@ -90,7 +90,7 @@ def get_pubkey_params(data):
9090

9191
if public_key_len != ED25519_PUBLIC_KEY_LENGTH:
9292
raise PacketParsingError(
93-
"bad ed25519 MPI length '{}', expected {}'".format( # pylint: disable=consider-using-f-string
93+
"bad ed25519 MPI length '{}', expected {}'".format(
9494
public_key_len, ED25519_PUBLIC_KEY_LENGTH
9595
)
9696
)
@@ -100,7 +100,7 @@ def get_pubkey_params(data):
100100

101101
if public_key_prefix != ED25519_PUBLIC_KEY_PREFIX:
102102
raise PacketParsingError(
103-
"bad ed25519 MPI prefix '{}', expected '{}'".format( # pylint: disable=consider-using-f-string
103+
"bad ed25519 MPI prefix '{}', expected '{}'".format(
104104
public_key_prefix, ED25519_PUBLIC_KEY_PREFIX
105105
)
106106
)

0 commit comments

Comments
 (0)