Skip to content

Skip .venv and .git when searching workspace #266

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 30, 2023

Conversation

bluss
Copy link
Contributor

@bluss bluss commented May 30, 2023

Skip .venv since it can contain stray pyprojects that are not related to
the current project. Further items could be ignored here.

Correctness fix (previously pyproject.toml installed into some package
in the environment, could ruin the sync), as well as a speed up since we
can skip scanning all the files in the environment.

Also change the order of member check and loading the project, it
seemed better to me in this order.

Fixes #260

@bluss
Copy link
Contributor Author

bluss commented May 30, 2023

Can ignore other files. Could ignore all with "." prefix for example.

The second commit can be dropped if there is some reason it's not the right change. It just seems a bit wrong to parse a file that we aren't even asked to read (because it's not in the workspace.)

bluss added 2 commits May 30, 2023 21:31
Skip .venv since it can contain stray pyprojects that are not related to
the current project. Further items could be ignored here.

Correctness fix (previously pyproject.toml installed into some package
in the environment, could ruin the sync), as well as a speed up since we
can skip scanning all the files in the environment.
Check if the project is a member before loading it. We shouldn't read
and report errors on projects that don't belong to the current
workspace.
@bluss bluss force-pushed the ignore-venv-workspace branch from 674a1e1 to b0919af Compare May 30, 2023 19:31
@mitsuhiko mitsuhiko merged commit 2f8e582 into astral-sh:main May 30, 2023
@mitsuhiko
Copy link
Collaborator

I think this is good. Thanks. Longer term it might make sense to investigate the ignore crate but maybe it's weird to magically ignore everything ignored by .gititnore.

mitsuhiko added a commit that referenced this pull request May 30, 2023
@bluss bluss deleted the ignore-venv-workspace branch May 30, 2023 21:28
@bluss
Copy link
Contributor Author

bluss commented May 30, 2023

Thanks for the nice work on rye.

For fun, maybe skipping .git seems weird. But just "git tag pyproject.toml" in a workspace and we would get (in rye 0.4.0):

    0: failed to parse pyproject.toml from [snip...]/.git/refs/tags/pyproject.toml in context of workspace [...]:
    1: TOML parse error at line 1, column 41
         |
       1 | 600a531ad4e481076ef62c3fb83505f57191e3c3
         |                                         ^
       expected `.`, `=`

@mitsuhiko
Copy link
Collaborator

No I agree that .git should be skipped. Maybe the non confusing thing would be to really skip anything with a leading .. I don't see that much harm in it. However the reason I thought ignore might be reasonable is that people might have node_modules and god knows what kind of nonsense is in there.

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.

workspace pyproject.toml iterator finds project files in .venv
2 participants