Skip to content

Commit ce1c5b4

Browse files
authored
chore(main): enforce flake8-pie rules (#122)
* fix: remove unnecessary 'pass' statements * fix: enforce PIE790 * fix: correct SECP521R1 value in ECCurve enum * fix(core): PIE810 & enforce other PIE rules * fix(core): enforce all PIE rules
1 parent 1c5f2c8 commit ce1c5b4

File tree

11 files changed

+5
-44
lines changed

11 files changed

+5
-44
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ lint.select = [
9191
"FURB", # refurb
9292
"I", # isort
9393
"PERF", # performance
94+
"PIE", # flake8-pie
9495
"PT018", # pytest style
9596
"PTH", # pathlib
9697
"Q", # flake8-quotes

src/otdf_python/autoconfigure_utils.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ def __hash__(self):
3939
class AutoConfigureException(Exception):
4040
"""Exception for auto-configuration errors."""
4141

42-
pass
43-
4442

4543
class AttributeNameFQN:
4644
"""Fully qualified attribute name."""

src/otdf_python/collection_store.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ class NoOpCollectionStore(CollectionStore):
2828

2929
def store(self, header, key: CollectionKey):
3030
"""Discard key operation (no-op)."""
31-
pass
3231

3332
def get_key(self, header) -> CollectionKey:
3433
return self.NO_PRIVATE_KEY

src/otdf_python/ecdh.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,14 @@
3535
class ECDHError(Exception):
3636
"""Base exception for ECDH operations."""
3737

38-
pass
39-
4038

4139
class UnsupportedCurveError(ECDHError):
4240
"""Raised when an unsupported curve is specified."""
4341

44-
pass
45-
4642

4743
class InvalidKeyError(ECDHError):
4844
"""Raised when a key is invalid or malformed."""
4945

50-
pass
51-
5246

5347
def get_curve(curve_name: str) -> ec.EllipticCurve:
5448
"""Get the cryptography curve object for a given curve name.

src/otdf_python/nanotdf.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,18 @@
2828
class NanoTDFException(SDKException):
2929
"""Base exception for NanoTDF operations."""
3030

31-
pass
32-
3331

3432
class NanoTDFMaxSizeLimit(NanoTDFException):
3533
"""Exception for NanoTDF size limit exceeded."""
3634

37-
pass
38-
3935

4036
class UnsupportedNanoTDFFeature(NanoTDFException):
4137
"""Exception for unsupported NanoTDF features."""
4238

43-
pass
44-
4539

4640
class InvalidNanoTDFConfig(NanoTDFException):
4741
"""Exception for invalid NanoTDF configuration."""
4842

49-
pass
50-
5143

5244
class NanoTDF:
5345
"""NanoTDF reader and writer for compact TDF format."""

src/otdf_python/nanotdf_ecdsa_struct.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
class IncorrectNanoTDFECDSASignatureSize(Exception):
77
"""Exception raised when the signature size is incorrect."""
88

9-
pass
10-
119

1210
@dataclass
1311
class NanoTDFECDSAStruct:

src/otdf_python/nanotdf_type.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class ECCurve(Enum):
88

99
SECP256R1 = "secp256r1"
1010
SECP384R1 = "secp384r1"
11-
SECP521R1 = "secp384r1"
11+
SECP521R1 = "secp521r1"
1212
SECP256K1 = "secp256k1"
1313

1414
def __str__(self):

src/otdf_python/sdk.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ def get_key_cache(self) -> Any:
134134

135135
def close(self):
136136
"""Close resources associated with KAS interface."""
137-
pass
138137

139138
def __exit__(self, exc_type, exc_val, exc_tb):
140139
self.close()
@@ -219,7 +218,6 @@ def kas(self) -> KAS:
219218

220219
def close(self):
221220
"""Close resources associated with the services."""
222-
pass
223221

224222
def __exit__(self, exc_type, exc_val, exc_tb):
225223
self.close()
@@ -377,23 +375,15 @@ def is_tdf(data: bytes | BinaryIO) -> bool:
377375
class SplitKeyException(SDKException):
378376
"""Throw when SDK encounters error related to split key operations."""
379377

380-
pass
381-
382378
class DataSizeNotSupported(SDKException):
383379
"""Throw when user attempts to create TDF larger than maximum size."""
384380

385-
pass
386-
387381
class KasInfoMissing(SDKException):
388382
"""Throw during TDF creation when no KAS information is present."""
389383

390-
pass
391-
392384
class KasPublicKeyMissing(SDKException):
393385
"""Throw during encryption when SDK cannot retrieve public key for KAS."""
394386

395-
pass
396-
397387
class TamperException(SDKException):
398388
"""Base class for exceptions related to signature mismatches."""
399389

@@ -407,18 +397,12 @@ class RootSignatureValidationException(TamperException):
407397
class SegmentSignatureMismatch(TamperException):
408398
"""Throw when segment signature does not match expected value."""
409399

410-
pass
411-
412400
class KasBadRequestException(SDKException):
413401
"""Throw when KAS returns bad request response."""
414402

415-
pass
416-
417403
class KasAllowlistException(SDKException):
418404
"""Throw when KAS allowlist check fails."""
419405

420-
pass
421-
422406
class AssertionException(SDKException):
423407
"""Throw when an assertion validation fails."""
424408

src/otdf_python/sdk_builder.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,7 @@ def set_platform_endpoint(self, endpoint: str) -> "SDKBuilder":
120120
121121
"""
122122
# Normalize the endpoint URL
123-
if endpoint and not (
124-
endpoint.startswith("http://") or endpoint.startswith("https://")
125-
):
123+
if endpoint and not (endpoint.startswith(("http://", "https://"))):
126124
if self.use_plaintext:
127125
endpoint = f"http://{endpoint}"
128126
else:
@@ -143,9 +141,7 @@ def set_issuer_endpoint(self, issuer: str) -> "SDKBuilder":
143141
144142
"""
145143
# Normalize the issuer URL
146-
if issuer and not (
147-
issuer.startswith("http://") or issuer.startswith("https://")
148-
):
144+
if issuer and not (issuer.startswith(("http://", "https://"))):
149145
issuer = f"https://{issuer}"
150146

151147
self.issuer_endpoint = issuer

tests/test_nanotdf_type.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def test_eccurve(self):
1818
"""Test ECCurve enum values."""
1919
self.assertEqual(str(ECCurve.SECP256R1), "secp256r1")
2020
self.assertEqual(str(ECCurve.SECP384R1), "secp384r1")
21-
self.assertEqual(str(ECCurve.SECP521R1), "secp384r1")
21+
self.assertEqual(str(ECCurve.SECP521R1), "secp521r1")
2222
self.assertEqual(str(ECCurve.SECP256K1), "secp256k1")
2323

2424
def test_protocol(self):

0 commit comments

Comments
 (0)