diff --git a/pyproject.toml b/pyproject.toml index b645a78..1ba828f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -91,6 +91,7 @@ lint.select = [ "FURB", # refurb "I", # isort "PERF", # performance + "PIE", # flake8-pie "PT018", # pytest style "PTH", # pathlib "Q", # flake8-quotes 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/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/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/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 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): 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():