mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-07-04 14:43:01 +02:00
feat: added flake8
This commit is contained in:
parent
f28bb77df1
commit
029a99aaba
@ -281,6 +281,50 @@ partial_branches = [
|
||||
# Note: Vulture uses command-line args, but we can document settings here
|
||||
# vulture --min-confidence 80 --exclude ".venv,Bash" .
|
||||
|
||||
# ============================================================================
|
||||
# FLAKE8 - Python linter (via Flake8-pyproject for pyproject.toml support)
|
||||
# ============================================================================
|
||||
[tool.flake8]
|
||||
# Maximum line length (matches ruff/black)
|
||||
max-line-length = 88
|
||||
# Maximum McCabe complexity (matches ruff C901 threshold)
|
||||
max-complexity = 10
|
||||
# Maximum cognitive complexity (flake8-cognitive-complexity)
|
||||
max-cognitive-complexity = 12
|
||||
# Maximum function length (flake8-functions)
|
||||
max-function-length = 50
|
||||
# Maximum returns/arguments per function
|
||||
max-returns = 6
|
||||
max-arguments = 5
|
||||
# Docstring convention (matches ruff)
|
||||
docstring-convention = "google"
|
||||
# Select all error codes
|
||||
select = ["E", "F", "W", "C", "B", "B950"]
|
||||
# Extend with plugin codes
|
||||
extend-select = ["B", "B9", "C4", "SIM", "PT", "TC", "ANN"]
|
||||
# Ignore rules that conflict with ruff-format or are duplicated
|
||||
extend-ignore = [
|
||||
"E501", # Line too long - B950 from bugbear is smarter (allows 10% overflow)
|
||||
"W503", # Line break before binary operator - contradicts PEP 8 update
|
||||
"ANN101", # Missing type annotation for self
|
||||
"ANN102", # Missing type annotation for cls
|
||||
]
|
||||
# Exclude directories
|
||||
exclude = [
|
||||
".git",
|
||||
".venv",
|
||||
"__pycache__",
|
||||
"build",
|
||||
"dist",
|
||||
".eggs",
|
||||
"Bash/ffmpeg-build",
|
||||
]
|
||||
# Per-file ignores
|
||||
per-file-ignores = [
|
||||
"**/tests/**/*.py:S101,ANN",
|
||||
"**/test_*.py:S101,ANN",
|
||||
]
|
||||
|
||||
# ============================================================================
|
||||
# PYDOCSTYLE - Docstring style checker (ruff handles this, but for standalone)
|
||||
# ============================================================================
|
||||
|
||||
@ -13,6 +13,7 @@ Usage:
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import contextlib
|
||||
from dataclasses import dataclass, field
|
||||
import fcntl
|
||||
import logging
|
||||
@ -243,11 +244,9 @@ def _drain_buffer(fd: int) -> None:
|
||||
"""Read and discard any stale data from the USB buffer."""
|
||||
flags = fcntl.fcntl(fd, fcntl.F_GETFL)
|
||||
fcntl.fcntl(fd, fcntl.F_SETFL, flags | os.O_NONBLOCK)
|
||||
try:
|
||||
with contextlib.suppress(OSError):
|
||||
while os.read(fd, 4096):
|
||||
pass
|
||||
except (BlockingIOError, OSError):
|
||||
pass
|
||||
fcntl.fcntl(fd, fcntl.F_SETFL, flags & ~os.O_NONBLOCK)
|
||||
|
||||
|
||||
@ -274,15 +273,13 @@ def pjl_query(fd: int, cmd: str, timeout_sec: float = 5.0) -> str:
|
||||
if readable:
|
||||
# Switch to non-blocking to read all available data
|
||||
fcntl.fcntl(fd, fcntl.F_SETFL, flags | os.O_NONBLOCK)
|
||||
try:
|
||||
with contextlib.suppress(OSError):
|
||||
while True:
|
||||
chunk = os.read(fd, 4096)
|
||||
if chunk:
|
||||
response += chunk
|
||||
else:
|
||||
break
|
||||
except (BlockingIOError, OSError):
|
||||
pass
|
||||
fcntl.fcntl(fd, fcntl.F_SETFL, flags & ~os.O_NONBLOCK)
|
||||
# If we got meaningful PJL data, stop waiting
|
||||
if response and (b"=" in response or b"@PJL" in response):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user