Skip to content

Commit dc5194e

Browse files
committed
lint: Enable flake8-self
Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
1 parent 9a61be1 commit dc5194e

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

examples/uploader/_localrepo.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,12 @@ def open(self, role: str) -> Metadata:
6262

6363
# if there is a metadata version fetched from remote, use that
6464
# HACK: access Updater internals
65-
if role in self.updater._trusted_set:
65+
trusted_set = self.updater._trusted_set # noqa: SLF001
66+
if role in trusted_set:
6667
# NOTE: The original signature wrapper (Metadata) was verified and
6768
# discarded upon inclusion in the trusted set. It is safe to use
6869
# a fresh wrapper. `close` will override existing signatures anyway.
69-
return Metadata(copy.deepcopy(self.updater._trusted_set[role]))
70+
return Metadata(copy.deepcopy(trusted_set[role]))
7071

7172
# otherwise we're creating metadata from scratch
7273
md = Metadata(Targets())

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ select = [
104104
"RUF", # ruff-specific rules
105105
"S", # flake8-bandit
106106
"SIM", # flake8-simplify
107+
"SLF", # flake8-self
107108
"UP", # pyupgrade
108109
"W", # pycodestyle-warning
109110
]
@@ -117,8 +118,9 @@ ignore = [
117118
"tests/*" = [
118119
"D", # pydocstyle: no docstrings required for tests
119120
"E501", # line-too-long: embedded test data in "fmt: off" blocks is ok
120-
"S", # bandit: Not running bandit on tests
121121
"RUF012", # ruff: mutable-class-default
122+
"S", # bandit: Not running bandit on tests
123+
"SLF001" # private member access is ok in tests
122124
]
123125
"examples/*/*" = [
124126
"D", # pydocstyle: no docstrings required for examples

tuf/ngclient/_internal/trusted_metadata_set.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,9 +490,9 @@ def _load_from_simple_envelope(
490490

491491
envelope = SimpleEnvelope[T].from_bytes(data)
492492

493-
if envelope.payload_type != SimpleEnvelope._DEFAULT_PAYLOAD_TYPE:
493+
if envelope.payload_type != SimpleEnvelope._DEFAULT_PAYLOAD_TYPE: # noqa: SLF001
494494
raise exceptions.RepositoryError(
495-
f"Expected '{SimpleEnvelope._DEFAULT_PAYLOAD_TYPE}', "
495+
f"Expected '{SimpleEnvelope._DEFAULT_PAYLOAD_TYPE}', " # noqa: SLF001
496496
f"got '{envelope.payload_type}'"
497497
)
498498

0 commit comments

Comments
 (0)