Skip to content

Duplicate _atomic_write_text in cli/main.py #468

Description

@SemTiOne

Summary

_atomic_write_text is defined twice in cli/main.py (lines 138 and 519). The second definition shadows the first, making it dead code.

Problem

Line 138:

def _atomic_write_text(path: Path, content: str) -> None:
    # wraps OSError in ConfigIOError

Line 519:

def _atomic_write_text(path: Path, content: str, encoding: str = "utf-8") -> None:
    # raises bare OSError

Python uses the last definition in module scope. Callers at lines 202, 218, 556, 1037 all hit the second version. The ConfigIOError wrapping at line 138 never fires.

Suggested fix

Delete the first definition (line 138-159). Keep the second (line 519-534) which has the encoding parameter and is the one actually used. Alternatively, consolidate both into a single function with the encoding parameter and ConfigIOError wrapping.

Files involved

  • cli/main.py (lines 138-159, 519-534)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:cliCLI commands and behaviorbugSomething isn't workinggood first issueGood for newcomerspriority:lowNice to have, low urgency

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions