Skip to content

Comments

[ty] Do not allow invalid virtual environments from discovered .venv or VIRTUAL_ENV#18003

Merged
zanieb merged 1 commit intomainfrom
zb/python-env-origin
May 10, 2025
Merged

[ty] Do not allow invalid virtual environments from discovered .venv or VIRTUAL_ENV#18003
zanieb merged 1 commit intomainfrom
zb/python-env-origin

Conversation

@zanieb
Copy link
Member

@zanieb zanieb commented May 10, 2025

Follow-up to #17991 ensuring we do not allow detection of system environments when the origin is VIRTUAL_ENV or a discovered .venv directory — i.e., those always require a pyvenv.cfg file.

impl SysPrefixPathOrigin {
/// Whether the given `sys.prefix` path must be a virtual environment (rather than a system
/// Python environment).
pub(crate) fn must_be_virtual_env(&self) -> bool {
Copy link
Member Author

@zanieb zanieb May 10, 2025

Choose a reason for hiding this comment

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

We could also frame this as allows_system_environment — no strong feelings here, easy to change as needed in the future.

@zanieb zanieb added the ty Multi-file analysis & type inference label May 10, 2025
@zanieb zanieb force-pushed the zb/python-env-origin branch 2 times, most recently from 7066570 to 17c64dc Compare May 10, 2025 12:56
@github-actions
Copy link
Contributor

github-actions bot commented May 10, 2025

mypy_primer results

No ecosystem changes detected ✅

@zanieb zanieb force-pushed the zb/python-env-origin branch from 17c64dc to 3439005 Compare May 10, 2025 14:43
@zanieb zanieb force-pushed the zb/python-env-test branch from 2f9a189 to c9653c0 Compare May 10, 2025 20:25
Base automatically changed from zb/python-env-test to main May 10, 2025 20:28
@zanieb zanieb force-pushed the zb/python-env-origin branch from 3439005 to a96d060 Compare May 10, 2025 20:31
@zanieb zanieb force-pushed the zb/python-env-origin branch from a96d060 to b0d6ac0 Compare May 10, 2025 20:32
@zanieb zanieb enabled auto-merge (squash) May 10, 2025 20:34
@zanieb zanieb merged commit 0bb8cbd into main May 10, 2025
31 checks passed
@zanieb zanieb deleted the zb/python-env-origin branch May 10, 2025 20:36
Glyphack pushed a commit to Glyphack/ruff that referenced this pull request May 21, 2025
…` or `VIRTUAL_ENV` (astral-sh#18003)

Follow-up to astral-sh#17991 ensuring we do
not allow detection of system environments when the origin is
`VIRTUAL_ENV` or a discovered `.venv` directory — i.e., those always
require a `pyvenv.cfg` file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants