Skip to content

Commit dd173ee

Browse files
committed
pre-commit fixes
1 parent e4143ba commit dd173ee

File tree

11 files changed

+44
-38
lines changed

11 files changed

+44
-38
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.14.10
3+
rev: v0.15.7
44
hooks:
55
# Run the linter, organize imports
66
- id: ruff-check
@@ -14,7 +14,7 @@ repos:
1414
exclude: ^(tests/|docs/) # keep in sync with mypy.ini
1515
additional_dependencies: []
1616
- repo: https://github.com/RobertCraigie/pyright-python
17-
rev: v1.1.407
17+
rev: v1.1.408
1818
hooks:
1919
- id: pyright
2020
- repo: local

pyproject.toml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ dependencies = [
2727

2828
[dependency-groups]
2929
dev = [
30-
"pytest>=8.0,<9",
30+
"pytest>=8.0,<10",
3131
"makefun>=1.9.5,<2",
3232
"pyinstaller>=6.10,<7",
3333
"sphinx>=7.4,<8",
@@ -70,3 +70,13 @@ venvPath = "."
7070
venv = ".venv"
7171
exclude = ["tests/", "docs/"]
7272
reportPrivateImportUsage = false
73+
74+
[tool.ty.src]
75+
exclude = ["docs"]
76+
77+
[[tool.ty.overrides]]
78+
include = ["tests/**", "**/test_*.py"]
79+
80+
[tool.ty.overrides.rules]
81+
unresolved-attribute = "ignore"
82+
invalid-argument-type = "ignore"

tests/device/cli/conftest.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
import pytest
55
from click.testing import CliRunner
6-
76
from ykman._cli.__main__ import cli
87
from ykman._cli.util import CliFail
98
from yubikit.core import TRANSPORT
@@ -21,7 +20,7 @@ def _ykman_cli(*argv, **kwargs):
2120
if result.exit_code != 0:
2221
if isinstance(result.exception, CliFail):
2322
raise SystemExit()
24-
raise result.exception
23+
raise result.exception # ty:ignore[invalid-raise]
2524
return result
2625

2726
if device.transport == TRANSPORT.NFC:

tests/device/condition.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ def has_transport(transport):
5555

5656
def capability(capability, transport=None):
5757
return check(
58-
lambda info, device: capability
59-
in info.config.enabled_capabilities.get(transport or device.transport, []),
58+
lambda info, device: (
59+
capability
60+
in info.config.enabled_capabilities.get(transport or device.transport, [])
61+
),
6062
f"Requires {capability}",
6163
)
6264

tests/test_device.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
serial=None,
1818
version=Version(5, 3, 0),
1919
form_factor=FORM_FACTOR.USB_A_KEYCHAIN,
20-
supported_capabilities={TRANSPORT.USB: CAPABILITY(0xFF)}, # type: ignore
20+
supported_capabilities={TRANSPORT.USB: CAPABILITY(0xFF)},
2121
is_locked=False,
2222
is_fips=False,
2323
)

tests/test_util.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import re
44

55
import pytest
6-
76
from ykman import __version__ as version
87
from ykman.otp import format_oath_code, generate_static_pw, time_challenge
98
from ykman.util import (
@@ -208,4 +207,4 @@ def test_form_factor_from_code(code, expected):
208207

209208
def test_form_factor_from_code_rejects_invalid_type():
210209
with pytest.raises(ValueError):
211-
FORM_FACTOR.from_code("im a string") # type: ignore[arg-type]
210+
FORM_FACTOR.from_code("im a string")

uv.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ykman/openpgp.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
import logging
2929
from datetime import datetime, timezone
30+
from typing import Any
3031

3132
from yubikit.core.smartcard import (
3233
AID,
@@ -129,7 +130,7 @@ def get_openpgp_info(session: OpenPgpSession):
129130
data = session.get_application_related_data()
130131
discretionary = data.discretionary
131132
retries = discretionary.pw_status
132-
info = {
133+
info: dict[str, Any] = {
133134
"OpenPGP version": "%d.%d" % data.aid.version,
134135
"Application version": "%d.%d.%d" % session.version,
135136
"PIN tries remaining": retries.attempts_user,

yubikit/core/smartcard/scp.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,7 @@ def __new__(cls, kid_or_data: int | bytes, kvn: int | None = None):
153153
raise ValueError("kvn can only be provided if kid_or_data is a kid")
154154
data = kid_or_data
155155

156-
# mypy thinks this is wrong
157-
return super(KeyRef, cls).__new__(cls, data) # type: ignore
156+
return super(KeyRef, cls).__new__(cls, data)
158157

159158
def __init__(self, kid_or_data: int | bytes, kvn: int | None = None):
160159
if len(self) != 2:
@@ -354,7 +353,7 @@ def scp11_init(
354353
# GPC v2.3 Amendment F (SCP11) v1.3 §3.1.2 Key Derivation
355354
key_agreement_data = data + epk_sd_ecka_tlv
356355
sharedinfo = key_usage + key_type + key_len
357-
keys = X963KDF(hashes.SHA256(), 5 * key_len[0], sharedinfo).derive(
356+
keybytes = X963KDF(hashes.SHA256(), 5 * key_len[0], sharedinfo).derive(
358357
esk_oce_ecka.exchange(
359358
ec.ECDH(),
360359
ec.EllipticCurvePublicKey.from_encoded_point(
@@ -366,7 +365,7 @@ def scp11_init(
366365

367366
# 5 keys were derived, one for verification of receipt
368367
ln = key_len[0]
369-
keys = [keys[i : i + ln] for i in range(0, ln * 5, ln)]
368+
keys = [keybytes[i : i + ln] for i in range(0, ln * 5, ln)]
370369
c = cmac.CMAC(algorithms.AES(keys.pop(0)))
371370
c.update(key_agreement_data)
372371
c.verify(receipt)

yubikit/openpgp.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -417,8 +417,7 @@ class KEY_STATUS(IntEnum):
417417
PrivateKey: TypeAlias = rsa.RSAPrivateKeyWithSerialization | EcPrivateKey
418418

419419

420-
# mypy doesn't handle abstract dataclasses well
421-
@dataclass # type: ignore[misc]
420+
@dataclass
422421
class AlgorithmAttributes(abc.ABC):
423422
"""OpenPGP key algorithm attributes."""
424423

@@ -686,8 +685,7 @@ def parse(cls, encoded: bytes) -> SecuritySupportTemplate:
686685
return cls(bytes2int(data[TAG_SIGNATURE_COUNTER]))
687686

688687

689-
# mypy doesn't handle abstract dataclasses well
690-
@dataclass # type: ignore[misc]
688+
@dataclass
691689
class Kdf(abc.ABC):
692690
algorithm: ClassVar[int]
693691

@@ -821,8 +819,7 @@ def __bytes__(self):
821819
)
822820

823821

824-
# mypy doesn't handle abstract dataclasses well
825-
@dataclass # type: ignore[misc]
822+
@dataclass
826823
class PrivateKeyTemplate(abc.ABC):
827824
crt: CRT
828825

0 commit comments

Comments
 (0)