Enable S101: replace assert with explicit checks in non-test code

- Replaced assert with RuntimeError in lichess_bot/main.py
- Added per-file-ignore for test_*.py pattern
This commit is contained in:
Krzysztof kuhy Rudnicki 2025-11-30 15:02:29 +01:00
parent 14612a6434
commit 8be643cd38
2 changed files with 9 additions and 3 deletions

View File

@ -295,7 +295,9 @@ def run_bot(log_level: str = "INFO", decline_correspondence: bool = False) -> No
lines: list[str] = []
ply_line_re = __import__("re").compile(r"^\s*(\d+)\s")
# Read stdout line by line
assert proc.stdout is not None
if proc.stdout is None:
msg = "subprocess stdout is None"
raise RuntimeError(msg)
for line in proc.stdout:
lines.append(line)
m = ply_line_re.match(line)
@ -321,7 +323,9 @@ def run_bot(log_level: str = "INFO", decline_correspondence: bool = False) -> No
)
# Capture any remaining stderr and ensure process ends
assert proc.stderr is not None
if proc.stderr is None:
msg = "subprocess stderr is None"
raise RuntimeError(msg)
stderr_text = proc.stderr.read() or ""
ret = proc.wait()
analysis_text = "".join(lines)

View File

@ -34,7 +34,6 @@ ignore = [
"COM812", # Trailing comma missing (conflicts with formatter)
"ISC001", # Implicit string concatenation (conflicts with formatter)
# Relaxed for script-heavy repository
"S101", # Use of assert - acceptable in this codebase
"ANN001", # Missing type annotation for function argument
"ANN002", # Missing type annotation for *args
"ANN003", # Missing type annotation for **kwargs
@ -102,6 +101,9 @@ unfixable = []
"S101", # Allow assert in tests
"PLR2004", # Allow magic values in tests
]
"**/test_*.py" = [
"S101", # Allow assert in tests
]
"**/conftest.py" = [
"D100", # Allow missing module docstring
"D103", # Allow missing function docstring