Skip to content

Commit b5022f4

Browse files
committed
Pyright type checker fails on cmds
Problem: The pyright type checker erroneously fails on the archivist/cmds directory. Solution: The archivist cmds directory does not contain library code but only the exposed entrypoints. The solution is to not bother checking the cmds subdirectory. Fixes AB#7653 Signed-off-by: Paul Hewlett <[email protected]>
1 parent e7cb843 commit b5022f4

File tree

12 files changed

+25
-31
lines changed

12 files changed

+25
-31
lines changed

.github/workflows/python-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
./scripts/version.sh
4545
pycodestyle --format=pylint archivist examples functests unittests
4646
python3 -m pylint archivist examples functests unittests
47-
python3 -m pyright archivist
47+
python3 -m pyright --stats archivist
4848
black archivist examples unittests functests
4949
./scripts/zipnotebooks.sh
5050
(cd docs && make clean && make html)

Taskfile.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ tasks:
4545
cmds:
4646
- ./scripts/builder.sh python3 --version
4747
- ./scripts/builder.sh ruff check archivist examples functests unittests
48-
- ./scripts/builder.sh python3 -m pyright archivist
48+
- ./scripts/builder.sh python3 -m pyright --stats archivist
4949
- ./scripts/builder.sh pycodestyle --format=pylint archivist examples functests unittests
5050
- ./scripts/builder.sh python3 -m pylint archivist examples functests unittests
5151

archivist/archivist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ def post_file(
308308

309309
response = self.session.post(
310310
url,
311-
data=multipart, # type: ignore https://github.com/requests/toolbelt/issues/312
311+
data=multipart, # pyright: ignore https://github.com/requests/toolbelt/issues/312
312312
headers=self._add_headers(headers),
313313
verify=self.verify,
314314
params=_dotdict(params),

archivist/confirmer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def _wait_for_confirmation(self: events._EventsPublic, identity: str) -> events.
7878

7979
@backoff.on_predicate(
8080
backoff.expo,
81-
logger=None, # type: ignore
81+
logger=None, # pyright: ignore
8282
max_time=__lookup_max_time,
8383
on_backoff=backoff_handler,
8484
on_giveup=__on_giveup_confirmation,
@@ -102,7 +102,7 @@ def _wait_for_confirmation(self: Managers, identity: str) -> ReturnTypes:
102102
if entity[CONFIRMATION_STATUS] == CONFIRMATION_CONFIRMED:
103103
return entity
104104

105-
return None # type: ignore
105+
return None # pyright: ignore
106106

107107

108108
def __on_giveup_confirmed(details: dict[str, Any]):
@@ -116,7 +116,7 @@ def __on_giveup_confirmed(details: dict[str, Any]):
116116

117117
@backoff.on_predicate(
118118
backoff.expo,
119-
logger=None, # type: ignore
119+
logger=None, # pyright: ignore
120120
max_time=__lookup_max_time,
121121
on_backoff=backoff_handler,
122122
on_giveup=__on_giveup_confirmed,

archivist/events.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,11 @@ def count(
187187
# asset_id will cause issues in the _identity function and the count function
188188
LOGGER.debug("asset_id %s", asset_id)
189189
LOGGER.debug(
190-
"event_id %s", f"{self._identity(asset_id)}/{EVENTS_LABEL}" # type:ignore
190+
"event_id %s",
191+
f"{self._identity(asset_id)}/{EVENTS_LABEL}", # pyright: ignore
191192
)
192193
return self._archivist.count(
193-
f"{self._identity(asset_id)}/{EVENTS_LABEL}", # type:ignore
194+
f"{self._identity(asset_id)}/{EVENTS_LABEL}", # pyright: ignore
194195
params=self._params(props, attrs, asset_attrs),
195196
)
196197

@@ -226,7 +227,7 @@ def list(
226227
return (
227228
Event(**a)
228229
for a in self._archivist.list(
229-
f"{self._identity(asset_id)}/{EVENTS_LABEL}", # type:ignore
230+
f"{self._identity(asset_id)}/{EVENTS_LABEL}", # pyright: ignore
230231
EVENTS_LABEL,
231232
page_size=page_size,
232233
params=self._params(props, attrs, asset_attrs),
@@ -262,7 +263,7 @@ def read_by_signature(
262263

263264
return Event(
264265
**self._archivist.get_by_signature(
265-
f"{self._identity(asset_id)}/{EVENTS_LABEL}", # type:ignore
266+
f"{self._identity(asset_id)}/{EVENTS_LABEL}", # pyright: ignore
266267
EVENTS_LABEL,
267268
params=self._params(props, attrs, asset_attrs),
268269
)

archivist/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def __init__(self, **kwargs):
4949

5050
def __call__(self, parser, namespace, values, option_string=None):
5151
# Convert value back into an Enum
52-
value = self._enum[values] # type: ignore
52+
value = self._enum[values] # pyright: ignore
5353
setattr(namespace, self.dest, value)
5454

5555

archivist/publisher.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def __on_giveup_publication(details):
3838

3939
@backoff.on_predicate(
4040
backoff.expo,
41-
logger=None, # type: ignore
41+
logger=None, # pyright: ignore
4242
max_time=__lookup_max_time,
4343
on_backoff=backoff_handler,
4444
on_giveup=__on_giveup_publication,
@@ -50,4 +50,4 @@ def _wait_for_publication(self: sboms._SBOMSClient, identity: str) -> sboms.SBOM
5050
if entity.published_date:
5151
return entity
5252

53-
return None # type: ignore
53+
return None # pyright: ignore

archivist/runner.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def action(self, action_name: str) -> Callable:
206206
Get valid action in map
207207
"""
208208
# if an exception occurs here then the dict initialized above is faulty.
209-
return self.ops(action_name).get("action") # type: ignore
209+
return self.ops(action_name).get("action") # pyright: ignore
210210

211211
def keywords(self, action_name: str) -> Tuple | None:
212212
"""
@@ -316,10 +316,10 @@ def label(self, verb: str, noun: str):
316316

317317
def identity_from_label(self, noun, identity_method):
318318
label = self.get(f"{noun}_label")
319-
if not label.startswith(f"{noun}s/"): # type: ignore
319+
if not label.startswith(f"{noun}s/"): # pyright: ignore
320320
return identity_method(label)
321321

322-
uid = label.split("/")[1] # type: ignore
322+
uid = label.split("/")[1] # pyright: ignore
323323
try:
324324
_ = UUID(uid, version=4)
325325
except ValueError:

archivist/subjects_confirmer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def __on_giveup_confirmation(details):
3939

4040
@backoff.on_predicate(
4141
backoff.expo,
42-
logger=None, # type: ignore
42+
logger=None, # pyright: ignore
4343
max_time=__lookup_max_time,
4444
on_backoff=backoff_handler,
4545
on_giveup=__on_giveup_confirmation,
@@ -50,9 +50,9 @@ def _wait_for_confirmation(
5050
"""Return None until subjects is confirmed"""
5151
subject = self.read(identity)
5252
if CONFIRMATION_STATUS not in subject:
53-
return None # type: ignore
53+
return None # pyright: ignore
5454

5555
if subject[CONFIRMATION_STATUS] == CONFIRMATION_CONFIRMED:
5656
return subject
5757

58-
return None # type: ignore
58+
return None # pyright: ignore

archivist/uploader.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def __on_giveup_uploading(details):
3535

3636
@backoff.on_predicate(
3737
backoff.expo,
38-
logger=None, # type: ignore
38+
logger=None, # pyright: ignore
3939
max_time=__lookup_max_time,
4040
on_backoff=backoff_handler,
4141
on_giveup=__on_giveup_uploading,
@@ -46,6 +46,6 @@ def _wait_for_uploading(self: sboms._SBOMSClient, identity: str) -> sboms.SBOM:
4646
LOGGER.debug("Uploader Read %s", identity)
4747
entity = self.read(identity)
4848
except ArchivistNotFoundError:
49-
return None # type: ignore
49+
return None # pyright: ignore
5050

5151
return entity

0 commit comments

Comments
 (0)