Skip to content

Commit 89cb47f

Browse files
committed
fix: Resolve remaining ruff linting and mypy issues
**Ruff fixes:** - E701 in utils.py: Break if statements with inline returns - E501 in base.py: Break long line in _open() function - F401 in in_out/__init__.py: Add __all__ to indicate re-exports - F403 in hide.py: Add noqa comments for wildcard import **MyPy fixes:** - transforms/registry.py: Remove None values from default dict - hide.py: Add type annotation for __all__: list[str] **Code cleanup:** - Improved readability of conditional statements - Proper module re-export declarations
1 parent 7c00140 commit 89cb47f

5 files changed

Lines changed: 19 additions & 11 deletions

File tree

‎src/redactable/detectors/utils.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ def nhs_check(n: str) -> bool:
4747
return check == int(n[-1])
4848

4949
def shannon_entropy(s: str) -> float:
50-
if not s: return 0.0
50+
if not s:
51+
return 0.0
5152
from collections import Counter
5253
counts = Counter(s)
5354
length = len(s)
@@ -57,5 +58,6 @@ def shannon_entropy(s: str) -> float:
5758
_HEXISH = re.compile(r'^[0-9a-fA-F]+$')
5859
def looks_like_secret(token: str) -> bool:
5960
# quick heuristic: base64/hex-ish + length
60-
if len(token) < 20: return False
61+
if len(token) < 20:
62+
return False
6163
return bool(_BASE64ISH.match(token) or _HEXISH.match(token))

‎src/redactable/hide.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
Use this as a main entrypoint?
33
"""
44

5-
from .decors import *
5+
from .decors import * # noqa: F401, F403
66

7-
__all__ = []
7+
__all__: list[str] = []

‎src/redactable/in_out/__init__.py‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
11
from .readers import TextFileReader
2-
from .writers import AuditJSONLWriter, StdoutWriter, TextFileWriter, Writer
2+
from .writers import AuditJSONLWriter, StdoutWriter, TextFileWriter, Writer
3+
4+
__all__ = [
5+
"TextFileReader",
6+
"AuditJSONLWriter",
7+
"StdoutWriter",
8+
"TextFileWriter",
9+
"Writer",
10+
]

‎src/redactable/in_out/base.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@ def close(self) -> None: ...
1515

1616

1717
def _open(path: str, mode: str):
18-
return gzip.open(path, mode) if str(path).endswith(".gz") else open(path, mode, encoding="utf-8", newline="")
18+
if str(path).endswith(".gz"):
19+
return gzip.open(path, mode)
20+
return open(path, mode, encoding="utf-8", newline="")

‎src/redactable/transforms/registry.py‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@ def __init__(self, transforms: Optional[Dict[str, Callable]] = None) -> None:
2222
@classmethod
2323
def default(cls) -> TransformRegistry:
2424
"""Return a registry preloaded with built-in transforms (v0.2)."""
25-
return cls({
26-
"redact": None,
27-
"mask": None,
28-
"tokenize": None,
29-
})
25+
return cls({})
3026

3127
def register(self, name: str, transform: Callable) -> None:
3228
"""Register a custom transformation function."""

0 commit comments

Comments
 (0)