Skip to content

Search import directories in a fixed order, once each (#1246) - #1300

Merged
jsiek merged 1 commit into
mainfrom
issue-1246-import-dirs
Nov 20, 2026
Merged

jsiek merged 1 commit into
mainfrom
issue-1246-import-dirs

Conversation

@jsiek

@jsiek jsiek commented Nov 20, 2026

Copy link
Copy Markdown
Owner

Fixes #1246.

Example

for seed in 1 2 3 4; do
  PYTHONHASHSEED=$seed python deduce.py --dir lib test/should-error/private_lemma_hint_stdlib.pf 2>&1 \
    | grep -o "in module Nat ([^)]*)"
done

Before, the path spelling depended on the hash seed:

in module Nat (lib/NatMult.pf:21)
in module Nat (lib/NatMult.pf:21)
in module Nat (/home/runner/deduce/lib/NatMult.pf:21)
in module Nat (/home/runner/deduce/lib/NatMult.pf:21)

After, every run prints in module Nat (lib/NatMult.pf:21).

Changes

  • flags.import_directories is now a list[str] searched in the order directories were added, not a set.
  • add_import_directory skips a directory whose os.path.realpath is already on the list, so the first spelling wins. init_import_directories goes through it too.
  • find_file and three LSP tests that monkeypatched the set with | {dir} are updated.
  • New test/unit/test_import_directories.py covers the deduplication and the ordering.

This also makes the choice deterministic when two different directories both hold a module with the same name: the one added first wins, where before it depended on set order.

Tests

make static, test-deduce.py and pytest test/lsp test/unit (1304 passed) all pass.

🤖 Generated with Claude Code

import_directories was a set, so a directory added under two spellings
(e.g. --dir lib plus the absolute stdlib path) stayed twice and the
spelling an import resolved to changed between runs. It is now a list
searched in the order added, and add_import_directory skips a directory
whose real path is already on it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jsiek
jsiek marked this pull request as ready for review November 20, 2026 13:29
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T13:30:36.006297Z 9b161c7 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@jsiek
jsiek merged commit 052c1b9 into main Nov 20, 2026
15 checks passed
@jsiek
jsiek deleted the issue-1246-import-dirs branch November 20, 2026 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error messages spell file paths differently between runs when an import directory is added twice

1 participant