From 3aab475c98c23af5cb44b4d5cfc5115810c978f5 Mon Sep 17 00:00:00 2001 From: b-long Date: Tue, 9 Dec 2025 12:24:57 -0500 Subject: [PATCH 1/5] fix: remove unnecessary 'pass' statements --- src/otdf_python/autoconfigure_utils.py | 2 -- src/otdf_python/collection_store.py | 1 - src/otdf_python/ecdh.py | 6 ------ src/otdf_python/nanotdf.py | 8 -------- src/otdf_python/nanotdf_ecdsa_struct.py | 2 -- src/otdf_python/sdk.py | 16 ---------------- tests/test_sdk.py | 1 - 7 files changed, 36 deletions(-) diff --git a/src/otdf_python/autoconfigure_utils.py b/src/otdf_python/autoconfigure_utils.py index ad7a04a..8b248c2 100644 --- a/src/otdf_python/autoconfigure_utils.py +++ b/src/otdf_python/autoconfigure_utils.py @@ -39,8 +39,6 @@ def __hash__(self): class AutoConfigureException(Exception): """Exception for auto-configuration errors.""" - pass - class AttributeNameFQN: """Fully qualified attribute name.""" diff --git a/src/otdf_python/collection_store.py b/src/otdf_python/collection_store.py index 215dbd8..c1e83f5 100644 --- a/src/otdf_python/collection_store.py +++ b/src/otdf_python/collection_store.py @@ -28,7 +28,6 @@ class NoOpCollectionStore(CollectionStore): def store(self, header, key: CollectionKey): """Discard key operation (no-op).""" - pass def get_key(self, header) -> CollectionKey: return self.NO_PRIVATE_KEY diff --git a/src/otdf_python/ecdh.py b/src/otdf_python/ecdh.py index eb093c1..da43cf1 100644 --- a/src/otdf_python/ecdh.py +++ b/src/otdf_python/ecdh.py @@ -35,20 +35,14 @@ class ECDHError(Exception): """Base exception for ECDH operations.""" - pass - class UnsupportedCurveError(ECDHError): """Raised when an unsupported curve is specified.""" - pass - class InvalidKeyError(ECDHError): """Raised when a key is invalid or malformed.""" - pass - def get_curve(curve_name: str) -> ec.EllipticCurve: """Get the cryptography curve object for a given curve name. diff --git a/src/otdf_python/nanotdf.py b/src/otdf_python/nanotdf.py index 75671f1..6a23e25 100644 --- a/src/otdf_python/nanotdf.py +++ b/src/otdf_python/nanotdf.py @@ -28,26 +28,18 @@ class NanoTDFException(SDKException): """Base exception for NanoTDF operations.""" - pass - class NanoTDFMaxSizeLimit(NanoTDFException): """Exception for NanoTDF size limit exceeded.""" - pass - class UnsupportedNanoTDFFeature(NanoTDFException): """Exception for unsupported NanoTDF features.""" - pass - class InvalidNanoTDFConfig(NanoTDFException): """Exception for invalid NanoTDF configuration.""" - pass - class NanoTDF: """NanoTDF reader and writer for compact TDF format.""" diff --git a/src/otdf_python/nanotdf_ecdsa_struct.py b/src/otdf_python/nanotdf_ecdsa_struct.py index 1e9214c..5abb4f5 100644 --- a/src/otdf_python/nanotdf_ecdsa_struct.py +++ b/src/otdf_python/nanotdf_ecdsa_struct.py @@ -6,8 +6,6 @@ class IncorrectNanoTDFECDSASignatureSize(Exception): """Exception raised when the signature size is incorrect.""" - pass - @dataclass class NanoTDFECDSAStruct: diff --git a/src/otdf_python/sdk.py b/src/otdf_python/sdk.py index 3666f69..df4c823 100644 --- a/src/otdf_python/sdk.py +++ b/src/otdf_python/sdk.py @@ -134,7 +134,6 @@ def get_key_cache(self) -> Any: def close(self): """Close resources associated with KAS interface.""" - pass def __exit__(self, exc_type, exc_val, exc_tb): self.close() @@ -219,7 +218,6 @@ def kas(self) -> KAS: def close(self): """Close resources associated with the services.""" - pass def __exit__(self, exc_type, exc_val, exc_tb): self.close() @@ -377,23 +375,15 @@ def is_tdf(data: bytes | BinaryIO) -> bool: class SplitKeyException(SDKException): """Throw when SDK encounters error related to split key operations.""" - pass - class DataSizeNotSupported(SDKException): """Throw when user attempts to create TDF larger than maximum size.""" - pass - class KasInfoMissing(SDKException): """Throw during TDF creation when no KAS information is present.""" - pass - class KasPublicKeyMissing(SDKException): """Throw during encryption when SDK cannot retrieve public key for KAS.""" - pass - class TamperException(SDKException): """Base class for exceptions related to signature mismatches.""" @@ -407,18 +397,12 @@ class RootSignatureValidationException(TamperException): class SegmentSignatureMismatch(TamperException): """Throw when segment signature does not match expected value.""" - pass - class KasBadRequestException(SDKException): """Throw when KAS returns bad request response.""" - pass - class KasAllowlistException(SDKException): """Throw when KAS allowlist check fails.""" - pass - class AssertionException(SDKException): """Throw when an assertion validation fails.""" diff --git a/tests/test_sdk.py b/tests/test_sdk.py index 5d84c54..1289209 100644 --- a/tests/test_sdk.py +++ b/tests/test_sdk.py @@ -12,7 +12,6 @@ def close(self): def __exit__(self, exc_type, exc_val, exc_tb): """Exit context manager.""" - pass def test_sdk_init_and_close(): From 6a4ec95b5b1fcaab0c06511e19f13b7517f771d9 Mon Sep 17 00:00:00 2001 From: b-long Date: Tue, 9 Dec 2025 12:25:29 -0500 Subject: [PATCH 2/5] fix: enforce PIE790 --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index b645a78..4e45f3a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -91,6 +91,7 @@ lint.select = [ "FURB", # refurb "I", # isort "PERF", # performance + "PIE790", # unnecessary 'pass' statements "PT018", # pytest style "PTH", # pathlib "Q", # flake8-quotes From 3d5932ab94c0a3570e8c6dc7a504841f2b338228 Mon Sep 17 00:00:00 2001 From: b-long Date: Tue, 9 Dec 2025 14:49:28 -0500 Subject: [PATCH 3/5] fix: correct SECP521R1 value in ECCurve enum --- pyproject.toml | 2 ++ src/otdf_python/nanotdf_type.py | 2 +- tests/test_nanotdf_type.py | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 4e45f3a..d4afc7f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -92,6 +92,8 @@ lint.select = [ "I", # isort "PERF", # performance "PIE790", # unnecessary 'pass' statements + "PIE794", # + "PIE796", # "PT018", # pytest style "PTH", # pathlib "Q", # flake8-quotes diff --git a/src/otdf_python/nanotdf_type.py b/src/otdf_python/nanotdf_type.py index 97d67e9..345a452 100644 --- a/src/otdf_python/nanotdf_type.py +++ b/src/otdf_python/nanotdf_type.py @@ -8,7 +8,7 @@ class ECCurve(Enum): SECP256R1 = "secp256r1" SECP384R1 = "secp384r1" - SECP521R1 = "secp384r1" + SECP521R1 = "secp521r1" SECP256K1 = "secp256k1" def __str__(self): diff --git a/tests/test_nanotdf_type.py b/tests/test_nanotdf_type.py index b7d788c..3d96467 100644 --- a/tests/test_nanotdf_type.py +++ b/tests/test_nanotdf_type.py @@ -18,7 +18,7 @@ def test_eccurve(self): """Test ECCurve enum values.""" self.assertEqual(str(ECCurve.SECP256R1), "secp256r1") self.assertEqual(str(ECCurve.SECP384R1), "secp384r1") - self.assertEqual(str(ECCurve.SECP521R1), "secp384r1") + self.assertEqual(str(ECCurve.SECP521R1), "secp521r1") self.assertEqual(str(ECCurve.SECP256K1), "secp256k1") def test_protocol(self): From 02e3058df14927fde0d762b1ef23b5faaa1f7aa4 Mon Sep 17 00:00:00 2001 From: b-long Date: Tue, 9 Dec 2025 15:13:02 -0500 Subject: [PATCH 4/5] fix(core): PIE810 & enforce other PIE rules --- pyproject.toml | 8 ++++++-- src/otdf_python/sdk_builder.py | 8 ++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d4afc7f..4e4ec10 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -92,8 +92,12 @@ lint.select = [ "I", # isort "PERF", # performance "PIE790", # unnecessary 'pass' statements - "PIE794", # - "PIE796", # + "PIE794", # duplicate class field definitions + "PIE796", # non-unique enum values + "PIE800", # unnecessary ... spread in dict literals + "PIE804", # unnecessary dict kwargs + "PIE807", # lambda can be replaced with function + "PIE810", # multiple starts-with/ends-with calls can be merged "PT018", # pytest style "PTH", # pathlib "Q", # flake8-quotes diff --git a/src/otdf_python/sdk_builder.py b/src/otdf_python/sdk_builder.py index f1c3499..2234ea2 100644 --- a/src/otdf_python/sdk_builder.py +++ b/src/otdf_python/sdk_builder.py @@ -120,9 +120,7 @@ def set_platform_endpoint(self, endpoint: str) -> "SDKBuilder": """ # Normalize the endpoint URL - if endpoint and not ( - endpoint.startswith("http://") or endpoint.startswith("https://") - ): + if endpoint and not (endpoint.startswith(("http://", "https://"))): if self.use_plaintext: endpoint = f"http://{endpoint}" else: @@ -143,9 +141,7 @@ def set_issuer_endpoint(self, issuer: str) -> "SDKBuilder": """ # Normalize the issuer URL - if issuer and not ( - issuer.startswith("http://") or issuer.startswith("https://") - ): + if issuer and not (issuer.startswith(("http://", "https://"))): issuer = f"https://{issuer}" self.issuer_endpoint = issuer From a78af05dfea711ee5672ac71b3276b7d418508b8 Mon Sep 17 00:00:00 2001 From: b-long Date: Tue, 9 Dec 2025 15:15:13 -0500 Subject: [PATCH 5/5] fix(core): enforce all PIE rules --- pyproject.toml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 4e4ec10..1ba828f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -91,13 +91,7 @@ lint.select = [ "FURB", # refurb "I", # isort "PERF", # performance - "PIE790", # unnecessary 'pass' statements - "PIE794", # duplicate class field definitions - "PIE796", # non-unique enum values - "PIE800", # unnecessary ... spread in dict literals - "PIE804", # unnecessary dict kwargs - "PIE807", # lambda can be replaced with function - "PIE810", # multiple starts-with/ends-with calls can be merged + "PIE", # flake8-pie "PT018", # pytest style "PTH", # pathlib "Q", # flake8-quotes