Skip to content

🐛 fix(env): reject a file as --env-dir and drop a mutable default#1100

Merged
henryiii merged 3 commits into
pypa:mainfrom
henryiii:henryiii/fix/env-robustness
Jun 13, 2026
Merged

🐛 fix(env): reject a file as --env-dir and drop a mutable default#1100
henryiii merged 3 commits into
pypa:mainfrom
henryiii:henryiii/fix/env-robustness

Conversation

@henryiii

Copy link
Copy Markdown
Contributor

🤖 AI text below 🤖

Two small robustness fixes in DefaultIsolatedEnv:

  • File-at-path check: when --env-dir points at an existing regular file, os.makedirs(..., exist_ok=True) previously raised a raw FileExistsError. Now a BuildException with a clear message (Build environment location is not a directory: <path>) is raised before reaching os.makedirs. A sibling test is added alongside the existing test_env_dir_rejects_non_empty_location test.
  • Mutable default argument: DefaultIsolatedEnv.install's constraints parameter had a mutable default [] (ruff B006). Changed to an empty tuple ().

Refs #1097

henryiii added 3 commits June 13, 2026 01:52
- Raise BuildException when --env-dir points at a regular file instead of
  letting os.makedirs produce a raw FileExistsError
- Change mutable default `constraints: Collection[str] = []` to `()` (B006)
- Add a test asserting the new "not a directory" error path

Assisted-by: ClaudeCode:claude-sonnet-4.6
Assisted-by: ClaudeCode:claude-sonnet-4.6
Assisted-by: ClaudeCode:claude-opus-4.8
@henryiii henryiii marked this pull request as ready for review June 13, 2026 06:01
@henryiii henryiii merged commit b1c53f9 into pypa:main Jun 13, 2026
59 checks passed
@henryiii henryiii deleted the henryiii/fix/env-robustness branch June 13, 2026 12:21
henryiii added a commit to henryiii/build that referenced this pull request Jun 14, 2026
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.

3 participants