-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
extend-select = ["I"]
from pyproject.toml not honored for tests in very specific circumstances
#12453
Comments
A few quick comments:
[tool.ruff]
src = ["src"] # The default here is `src = ["."]`
|
Do you want imports of |
I believe I'm asking for There might still something bizarre going on here, because doing certain things to tests/ can cause |
Are you sure that |
You know what, I think you might be right. What does MRE mean? |
Apologies, MRE is "minimal reproducible example". |
So with my new found understanding, I'm trying to figure out if there's an issue worth keeping around or not, even if it's not this specific issue. I'm leaning towards "no", but I want to run my thoughts by you regardless:
If any of these are worth keeping around, I can file a separate issue. If not, I'll close this ticket after I give my coworkers some time to skim over. |
Well put! I've been wanting to add
Yeah this is a legitimate bug / footgun, I believe it's covered here: #10519. |
I'm going to close out in favor of those other issues (e.g., #12454), thanks for taking the time to dig into this and for your thoughts. |
Thank you for taking the time to interact & help me understand, I appreciate the project's helpfulness |
## Summary Occasionally, we receive bug reports that imports in `src` directories aren't correctly detected. The root of the problem is that we default to `src = ["."]`, so users have to set `src = ["src"]` explicitly. This PR extends the default to cover _both_ of them: `src = [".", "src"]`. Closes #12454. ## Test Plan I replicated the structure described in #12453, and verified that the imports were considered sorted, but that adding `src = ["."]` showed an error.
## Summary Occasionally, we receive bug reports that imports in `src` directories aren't correctly detected. The root of the problem is that we default to `src = ["."]`, so users have to set `src = ["src"]` explicitly. This PR extends the default to cover _both_ of them: `src = [".", "src"]`. Closes #12454. ## Test Plan I replicated the structure described in #12453, and verified that the imports were considered sorted, but that adding `src = ["."]` showed an error.
## Summary Occasionally, we receive bug reports that imports in `src` directories aren't correctly detected. The root of the problem is that we default to `src = ["."]`, so users have to set `src = ["src"]` explicitly. This PR extends the default to cover _both_ of them: `src = [".", "src"]`. Closes #12454. ## Test Plan I replicated the structure described in #12453, and verified that the imports were considered sorted, but that adding `src = ["."]` showed an error.
## Summary Occasionally, we receive bug reports that imports in `src` directories aren't correctly detected. The root of the problem is that we default to `src = ["."]`, so users have to set `src = ["src"]` explicitly. This PR extends the default to cover _both_ of them: `src = [".", "src"]`. Closes #12454. ## Test Plan I replicated the structure described in #12453, and verified that the imports were considered sorted, but that adding `src = ["."]` showed an error.
We've observed an odd behavior where the
extend-select = ["I"]
is not honored for code intests/
when a very specific set of circumstances occur. I'm not even sure I have the minimum reproduction steps completely down, but I can very consistently reproduce the situation.mod1
src
instead of the repo rootmod1
exists at the repo root. This directory can be emptytests/test_mod1.py
. Modifying the file contents can in some cases causeextend-select
frompyproject.toml
to be respected. Some of these are very insignificant changes, like insertion of a comment between imports, removal of a blank line between imports, etc.ruff check --no-cache
and observe thattests/test_mod1.py
is not checked forI001
as requested inpyproject.toml
. Be sure to use--no-cache
during tests because some actions will not invalidate the cache that otherwise would, like creating/removing the top-levelmod1
directory.The minimum reproduction is below, but is also available as a git repository https://github.com/jamesharr/ruff-issue-12453
This bug was initially spotted due to a dirty working directory, and we eventually narrowed it down to an empty to-level folder that matches one of the modules a test imports. Of course git ignores empty directories, so we were chasing our tails on this one for a few days.
Ruff version:
ruff 0.5.4
on macOS 14.5, though we've also seen it with 0.5.2 and 0.5.3Command:
ruff check --no-cache .
Directory structure:
Contents of
pyproject.toml
Contents of
tests/test_mod1.py
The text was updated successfully, but these errors were encountered: