Skip to content

Refactor: directives/include.py mixed-type cycle-detection set is fragileΒ #154

@tcconnally

Description

@tcconnally

Severity: 🟑 Medium (code quality)

directives/include.py:48–56 mixes string paths and (inode, dev) tuples in a single _visited: set. Works because both are hashable, but fragile and confusing.

Suggested fix

_visited_paths: set[str] = set()
_visited_inodes: set[tuple[int, int]] = set()

Thread both sets through the recursion. Update the cycle-detection check and the chain-print formatting to be type-aware.

Acceptance criteria

  • Refactor passes existing test_include_cycle tests.
  • Add a test: include via two different relative paths that resolve to the same inode β†’ cycle detected and chain prints clearly.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions