Skip to content

fix: take metadata hooks from project - #2351

Merged
cjames23 merged 4 commits into
pypa:masterfrom
flying-sheep:fix-metadata
Jul 23, 2026
Merged

fix: take metadata hooks from project#2351
cjames23 merged 4 commits into
pypa:masterfrom
flying-sheep:fix-metadata

Conversation

@flying-sheep

@flying-sheep flying-sheep commented Jul 21, 2026

Copy link
Copy Markdown
Member

Fixes #2345

I also added type annotations to the file and changed all mutable cached_propertys to be immutable, see below:

Comment thread src/hatch/utils/runner.py
Comment on lines -22 to +24
self.shell_commands: list[str] = shell_commands or []
self.shell_commands: list[str] = list(shell_commands) if shell_commands else []

@flying-sheep flying-sheep Jul 21, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s bad to have cached_propertys that return a mutable value, as you can see here: this line was a bug waiting to happen, as shell_commands gets modified here. Which modifies the cached list in-place, so passing ExecutionContext(..., shell_commands=env_interface.shell_commands) used to modify env_interface in-place.

@cjames23 cjames23 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking this on! And fixing some of the types that I was hoping to get to this week myself!

@cjames23
cjames23 merged commit af5339a into pypa:master Jul 23, 2026
49 checks passed
github-actions Bot pushed a commit that referenced this pull request Jul 23, 2026
* fix: call hooks from project

* fix more types

* fix lints

* fmt af5339a
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.

env creation fails when self-referential extra and 3rd-party metadata hook exist

2 participants