-
Notifications
You must be signed in to change notification settings - Fork 32
Fix remaining ty static type checker warnings and errors. #139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1372,7 +1372,7 @@ def decode_key(self, key: BytesOrStr) -> None: | |
| raise WolfCryptError(f"Key decode error ({self.max_signature_size})") | ||
|
|
||
| @override | ||
| def decode_key_raw(self, qx: BytesOrStr, qy: BytesOrStr, d: BytesOrStr, curve_id: int = ECC_SECP256R1) -> None: | ||
| def decode_key_raw(self, qx: BytesOrStr, qy: BytesOrStr, d: BytesOrStr, curve_id: int = ECC_SECP256R1) -> None: # ty: ignore[invalid-method-override] | ||
| """ | ||
| Decodes an ECC private key from its raw elements: public (Qx,Qy) | ||
| and private(d) | ||
|
|
@@ -1394,7 +1394,7 @@ def decode_key_raw(self, qx: BytesOrStr, qy: BytesOrStr, d: BytesOrStr, curve_id | |
| raise WolfCryptApiError("Key decode error", ret) | ||
|
|
||
| @override | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 [High] EccPrivate.encode_key() accepts with_curve but silently ignores it To silence ty's This is a behavioral regression, not just dead code. Before this PR, It is also inconsistent with the rest of this same diff. The four other override mismatches touched here ( Fix: Revert the signature to |
||
| def encode_key(self) -> bytes: | ||
| def encode_key(self, with_curve: bool = True) -> bytes: | ||
| """ | ||
| Encodes the ECC private key in an ASN sequence. | ||
|
|
||
|
|
@@ -1409,7 +1409,7 @@ def encode_key(self) -> bytes: | |
| return _ffi.buffer(key, ret)[:] | ||
|
|
||
| @override | ||
| def encode_key_raw(self) -> tuple[bytes, bytes, bytes]: | ||
| def encode_key_raw(self) -> tuple[bytes, bytes, bytes]: # ty: ignore[invalid-method-override] | ||
| """ | ||
| Encodes the ECC private key in its three raw elements | ||
|
|
||
|
|
@@ -1680,7 +1680,7 @@ def decode_key(self, key: BytesOrStr, pub: bytes | None = None) -> None: | |
| raise WolfCryptError(f"Key decode error ({self.max_signature_size})") | ||
|
|
||
| @override | ||
| def encode_key(self) -> tuple[bytes, bytes]: | ||
| def encode_key(self) -> tuple[bytes, bytes]: # ty: ignore[invalid-method-override] | ||
| """ | ||
| Encodes the ED25519 private key. | ||
|
|
||
|
|
@@ -1889,7 +1889,7 @@ def decode_key(self, key: BytesOrStr, pub: bytes | None = None) -> None: | |
| raise WolfCryptError(f"Key decode error ({self.max_signature_size})") | ||
|
|
||
| @override | ||
| def encode_key(self) -> tuple[bytes, bytes]: | ||
| def encode_key(self) -> tuple[bytes, bytes]: # ty: ignore[invalid-method-override] | ||
| """ | ||
| Encodes the ED448 private key. | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -457,6 +457,7 @@ class _Hmac(_Hash): | |
| digest_size = None | ||
| _native_type = "Hmac *" | ||
| _native_size = _ffi.sizeof("Hmac") | ||
| _type: int | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔵 [Low] _type should be annotated ClassVar[int], not int
Fix: Change the annotation to |
||
| _delete = staticmethod(_lib.wc_HmacFree) | ||
|
|
||
| @override | ||
|
|
@@ -498,11 +499,6 @@ def new(cls, key: BytesOrStr, string: BytesOrStr | None = None) -> _Hash: # pyl | |
| """ | ||
| return cls(key, string) | ||
|
|
||
|
|
||
| @property | ||
| @abstractmethod | ||
| def _type(self) -> int: ... | ||
|
|
||
| def _hmac_init(self, hmac: int, key: bytes) -> int: | ||
| ret = _lib.wc_HmacInit(self._native_object, _ffi.NULL, -2) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 [Medium] _Hmac is no longer abstract after removing the _type abstractmethod The diff deletes the Walking the ABC bookkeeping: Concretely: Fix: Restore an equivalent guard so a missing |
||
| if ret < 0: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟠 [Medium] New uv run ty check CI gate may never fail the build
The PR's stated purpose is to "allow to run ty check in the pipeline static checks step," but the step as written may be a no-op gate.
pyproject.tomlcontains[tool.ty.rules]withall = "warn", which downgrades every ty rule from its default severity to warning level.ty checkexits non-zero for error-level diagnostics; warning-level diagnostics require the--error-on-warningflag to affect the exit code. If that is the case here, the step will print diagnostics to the CI log and still exit 0, so the type regressions this PR just spent effort eliminating could silently reappear without turning CI red.The multi-command
run: |block itself is fine -- GitHub Actions usesbash -e {0}on Linux, so a failinguv run ruff checkwill still abort beforety check.Fix: Verify the gate actually blocks: temporarily introduce a deliberate type error on the branch and confirm the job goes red. If it does not, either add
--error-on-warningto the CI invocation or promote the rules that should be blocking from"warn"to"error"in[tool.ty.rules].