Skip to content

Commit e8a1193

Browse files
committed
py(ruff[N]) Enforce pep8-naming
why: N surfaces identifiers that drift from Python naming norms -- camelCase locals and exception classes without an Error suffix -- which hurt grep-ability and readability. Enabling it after the exception renames keeps the rule clean with no suppressions. what: - Add "N" to [tool.ruff.lint].select - Lowercase the module_funcName local in log.py (N806) - Suffix the test-local _Boom sentinel as _BoomError (N818)
1 parent 6e20c56 commit e8a1193

3 files changed

Lines changed: 6 additions & 5 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ select = [
214214
"F", # pyflakes
215215
"I", # isort
216216
"UP", # pyupgrade
217+
"N", # pep8-naming
217218
"A", # flake8-builtins
218219
"B", # flake8-bugbear
219220
"C4", # flake8-comprehensions

src/vcspull/log.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ def template(self, record: logging.LogRecord) -> str:
295295
Style.RESET_ALL,
296296
" ",
297297
]
298-
module_funcName = [Fore.GREEN, Style.BRIGHT, "%(module)s.%(funcName)s()"]
298+
module_func_name = [Fore.GREEN, Style.BRIGHT, "%(module)s.%(funcName)s()"]
299299
lineno = [
300300
Fore.BLACK,
301301
Style.DIM,
@@ -307,7 +307,7 @@ def template(self, record: logging.LogRecord) -> str:
307307
]
308308

309309
return "".join(
310-
reset + levelname + asctime + name + module_funcName + lineno + reset,
310+
reset + levelname + asctime + name + module_func_name + lineno + reset,
311311
)
312312

313313

tests/cli/test_sync_watchdog.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,14 @@ def test_watchdog_preserves_failed_outcome(
127127
) -> None:
128128
"""Synchronous exceptions from ``update_repo`` surface as ``failed``."""
129129

130-
class _Boom(RuntimeError):
130+
class _BoomError(RuntimeError):
131131
"""Sentinel used to trace exception propagation."""
132132

133133
def _raising_update_repo(
134134
repo: dict[str, t.Any], *, progress_callback: t.Any
135135
) -> None:
136136
msg = "remote exploded"
137-
raise _Boom(msg)
137+
raise _BoomError(msg)
138138

139139
monkeypatch.setattr(sync_module, "update_repo", _raising_update_repo)
140140

@@ -146,7 +146,7 @@ def _raising_update_repo(
146146
)
147147

148148
assert outcome.status == "failed"
149-
assert isinstance(outcome.error, _Boom)
149+
assert isinstance(outcome.error, _BoomError)
150150
assert "remote exploded" in str(outcome.error)
151151

152152

0 commit comments

Comments
 (0)