Skip to content

Commit 4ea2e6d

Browse files
Patrick Roebuckclaude
andcommitted
fix: Resolve ruff linting errors for CI
- Fix A002 (shadowing builtin 'format'): Rename format params to export_format/output_format - Fix N806 (variable naming): Rename PascalCase class variables to snake_case - Fix UP045: Use 'X | None' instead of Optional[X] - Fix F401: Remove unused imports (parse_qs, os) - Fix B009: Replace getattr with direct attribute access All critical linting issues resolved for GitHub Actions CI to pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 559e395 commit 4ea2e6d

File tree

8 files changed

+30
-30
lines changed

8 files changed

+30
-30
lines changed

memdocs/cli_modules/commands/export_cmd.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616

1717
@click.command()
18-
@click.argument("format", type=click.Choice(["cursor", "claude", "continue"]))
18+
@click.argument("export_format", type=click.Choice(["cursor", "claude", "continue"]))
1919
@click.option(
2020
"--output",
2121
type=click.Path(path_type=Path),
@@ -32,7 +32,7 @@
3232
default=True,
3333
help="Include code symbols in export",
3434
)
35-
def export(format: str, output: Path | None, docs_dir: Path, include_symbols: bool) -> None:
35+
def export(export_format: str, output: Path | None, docs_dir: Path, include_symbols: bool) -> None:
3636
"""Export docs for AI assistants.
3737
3838
Examples:
@@ -42,7 +42,7 @@ def export(format: str, output: Path | None, docs_dir: Path, include_symbols: bo
4242
memdocs export continue
4343
"""
4444
out.print_header("MemDocs Export")
45-
out.step(f"Exporting to [cyan]{format}[/cyan] format")
45+
out.step(f"Exporting to [cyan]{export_format}[/cyan] format")
4646

4747
if not docs_dir.exists():
4848
out.error(f"Docs directory not found: {docs_dir}")
@@ -107,7 +107,7 @@ def export(format: str, output: Path | None, docs_dir: Path, include_symbols: bo
107107
graph_section += f"- {feature.get('title', 'Untitled')}\n"
108108

109109
# Format based on target
110-
if format == "cursor":
110+
if export_format == "cursor":
111111
output_path = output or Path(".cursorrules")
112112
content = f"""# Project Memory (Auto-generated by doc-intelligence)
113113
# Last updated: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}
@@ -133,7 +133,7 @@ def export(format: str, output: Path | None, docs_dir: Path, include_symbols: bo
133133
*Regenerate with: `memdocs export cursor`*
134134
"""
135135

136-
elif format == "continue":
136+
elif export_format == "continue":
137137
output_path = output or Path(".continue/context.md")
138138
content = f"""# Project Context
139139

memdocs/cli_modules/commands/init_cmd.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66
import os
77
import sys
88
from pathlib import Path
9-
from typing import Optional
9+
from typing import Any
1010

1111
import click
1212

1313
from memdocs import cli_output as out
1414
from memdocs.security import PathValidator
1515

1616

17-
def _detect_project_type(cwd: Path) -> dict[str, any]:
17+
def _detect_project_type(cwd: Path) -> dict[str, Any]:
1818
"""Detect project type and return metadata."""
19-
project_info: dict[str, any] = {
19+
project_info: dict[str, Any] = {
2020
"type": "unknown",
2121
"language": None,
2222
"source_dir": None,
@@ -182,7 +182,7 @@ def _setup_mcp_infrastructure(cwd: Path) -> None:
182182
default=None,
183183
help="Interactive mode (auto-detects TTY if not specified)",
184184
)
185-
def init(force: bool, no_mcp: bool, interactive: Optional[bool]) -> None:
185+
def init(force: bool, no_mcp: bool, interactive: bool | None) -> None:
186186
"""Initialize MemDocs in the current project.
187187
188188
MCP auto-start is enabled by default for VS Code/Cursor integration.

memdocs/cli_modules/commands/query_cmd.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ def query(query: str, k: int, memory_dir: Path) -> None:
4343
out.print_header("MemDocs Query")
4444
out.step(f'Searching for: [cyan]"{query}"[/cyan]')
4545

46-
MemoryIndexer = _get_memory_indexer()
47-
indexer = MemoryIndexer(memory_dir=memory_dir, use_embeddings=True)
46+
memory_indexer_class = _get_memory_indexer()
47+
indexer = memory_indexer_class(memory_dir=memory_dir, use_embeddings=True)
4848

4949
if not indexer.use_embeddings:
5050
out.error("Embeddings not available")

memdocs/cli_modules/commands/review_cmd.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,21 +232,21 @@ def review(
232232
sys.exit(1)
233233

234234
# Get CLI classes (lazy import)
235-
Extractor, MemoryIndexer, PolicyEngine, Summarizer = _get_cli_classes()
235+
extractor_class, memory_indexer_class, policy_engine_class, summarizer_class = _get_cli_classes()
236236

237237
out.print_header("MemDocs Review")
238238
out.step(f"Reviewing {len(paths)} path(s) for [cyan]{event}[/cyan] event")
239239

240240
# Extract context
241241
with out.spinner(f"Extracting context from {len(paths)} path(s)"):
242-
extractor = Extractor(repo_path=Path("."))
242+
extractor = extractor_class(repo_path=Path("."))
243243
context = extractor.extract_context(paths)
244244

245245
out.success(f"Extracted context from {len(context.files)} files")
246246

247247
# Apply policy
248248
out.step("Determining scope")
249-
policy_engine = PolicyEngine(doc_config)
249+
policy_engine = policy_engine_class(doc_config)
250250
scope = policy_engine.determine_scope(paths, context, force=force)
251251

252252
# Show warnings
@@ -266,7 +266,7 @@ def review(
266266

267267
# Summarize with AI
268268
with out.spinner("Generating documentation with Claude Sonnet 4.5"):
269-
summarizer = Summarizer(model=doc_config.ai.model, max_tokens=doc_config.ai.max_tokens)
269+
summarizer = summarizer_class(model=doc_config.ai.model, max_tokens=doc_config.ai.max_tokens)
270270
doc_index, markdown_summary = summarizer.summarize(context, scope)
271271

272272
out.success("Documentation generated")
@@ -293,7 +293,7 @@ def review(
293293

294294
# Generate embeddings (optional, v1.1)
295295
try:
296-
indexer = MemoryIndexer(
296+
indexer = memory_indexer_class(
297297
memory_dir=doc_config.outputs.memory_dir, use_embeddings=True
298298
)
299299

memdocs/cli_modules/commands/serve_cmd.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from http.server import BaseHTTPRequestHandler, HTTPServer
1010
from pathlib import Path
1111
from typing import Any
12-
from urllib.parse import parse_qs, urlparse
12+
from urllib.parse import urlparse
1313

1414
import click
1515

@@ -19,7 +19,7 @@
1919
class MemDocsHTTPHandler(BaseHTTPRequestHandler):
2020
"""HTTP handler for MemDocs MCP server."""
2121

22-
def log_message(self, format: str, *args: Any) -> None:
22+
def log_message(self, format: str, *args: Any) -> None: # noqa: A002
2323
"""Override to use our logger."""
2424
if self.server.verbose: # type: ignore
2525
out.info(f"{self.address_string()} - {format % args}")
@@ -110,8 +110,8 @@ def _send_error(self, code: int, message: str) -> None:
110110

111111
def _get_stats(self) -> dict[str, Any]:
112112
"""Get memory statistics."""
113-
docs_dir = getattr(self.server, "docs_dir") # type: ignore
114-
memory_dir = getattr(self.server, "memory_dir") # type: ignore
113+
docs_dir = self.server.docs_dir # type: ignore
114+
memory_dir = self.server.memory_dir # type: ignore
115115

116116
stats: dict[str, Any] = {
117117
"docs_dir": str(docs_dir),

memdocs/cli_modules/commands/setup_hooks_cmd.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
Setup-hooks command - Install git hooks for automatic memory updates.
33
"""
44

5-
import os
65
import subprocess
76
import sys
87
from pathlib import Path

memdocs/cli_modules/commands/stats_cmd.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ def _get_memory_indexer():
3232
)
3333
@click.option(
3434
"--format",
35+
"output_format",
3536
type=click.Choice(["table", "json"]),
3637
default="table",
3738
help="Output format",
3839
)
39-
def stats(docs_dir: Path, memory_dir: Path, format: str) -> None:
40+
def stats(docs_dir: Path, memory_dir: Path, output_format: str) -> None:
4041
"""Show memory and documentation statistics.
4142
4243
Examples:
@@ -77,14 +78,14 @@ def stats(docs_dir: Path, memory_dir: Path, format: str) -> None:
7778
# Embedding index stats
7879
index_stats = None
7980
try:
80-
MemoryIndexer = _get_memory_indexer()
81-
indexer = MemoryIndexer(memory_dir=memory_dir, use_embeddings=True)
81+
memory_indexer_class = _get_memory_indexer()
82+
indexer = memory_indexer_class(memory_dir=memory_dir, use_embeddings=True)
8283
if indexer.use_embeddings:
8384
index_stats = indexer.get_stats()
8485
except Exception:
8586
pass
8687

87-
if format == "json":
88+
if output_format == "json":
8889
# JSON output
8990
output = {
9091
"docs": docs_stats,

memdocs/security.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -319,11 +319,11 @@ def validate_scope_level(scope: str) -> str:
319319
return scope
320320

321321
@staticmethod
322-
def validate_output_format(format: str) -> str:
322+
def validate_output_format(output_format: str) -> str:
323323
"""Validate output format.
324324
325325
Args:
326-
format: Output format to validate
326+
output_format: Output format to validate
327327
328328
Returns:
329329
Validated format
@@ -332,11 +332,11 @@ def validate_output_format(format: str) -> str:
332332
ValueError: If format is invalid
333333
"""
334334
valid_formats = ["json", "yaml", "markdown"]
335-
if format not in valid_formats:
335+
if output_format not in valid_formats:
336336
raise ValueError(
337-
f"Invalid format '{format}'. Valid formats: {', '.join(valid_formats)}"
337+
f"Invalid format '{output_format}'. Valid formats: {', '.join(valid_formats)}"
338338
)
339-
return format
339+
return output_format
340340

341341
@staticmethod
342342
def validate_positive_int(value: int, name: str, min_value: int = 1) -> int:

0 commit comments

Comments
 (0)