-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Allow configuration to be defined on a file-scoped basis #7696
Comments
That makes sense. Have you tried using a hierarchical configuration to achieve your goal? The way this works is that you create a new |
Unfortuantelly in this project (napari), test are not stored in a separate directory but in |
Really wishing we had ESLint-style file overrides, as in: {
"rules": {
"quotes": ["error", "double"]
},
"overrides": [
{
"files": ["bin/*.js", "lib/*.js"],
"excludedFiles": "*.test.js",
"rules": {
"quotes": ["error", "single"]
}
}
]
} |
cibuildwheel project use toml tables to implement overwrite rules inside pyproject.toml https://github.com/pypa/cibuildwheel/ Maybe it could be an inspiration? |
I've mixed feelings about {
"rules": {
"quotes": ["error", "double"]
},
"overrides": [
{
"files": ["bin/*.js", "lib/*.js"],
"excludedFiles": "*.test.js",
"rules": {
"quotes": ["error", "single"]
}
}
]
} and {
"extend": "config-above.json",
"rules": {
"quotes": ["error", "double"]
}
} What does now bind stronger, the parent configuration because it's in the |
(Making this issue more general -- it would be nice to support something like ESLint's flat configuration, in which you can define configuration that only applies to a subset of files.) |
i'm fine with hierarchical configuration, but the only problem is that i wish it would inherit the # ./pyproject.toml
[tool.ruff.flake8-tidy-imports.banned-api]
"foo".msg = "banned project-wide" # ./tests/ruff.toml
extend = "../pyproject.toml"
[flake8-tidy-imports.banned-api]
"bar".msg = "only banned in tests" # tests/test_foo.py
import foo # no error, because the `banned-api` the `tests` directory doesn't inherit from the global one |
In my case #7890 we want to configure isort on file-scope basis, and in our particular need the hierarchical solution is not feasible, as we want it for every init.py file. Is there any progress on this topic @charliermarsh ? |
@charliermarsh Is there any progress on configure isort on file-scope basis? |
It will be nice to allow define
banned-api
rules per file pattern.In general, there are API that may be useful in tests but should not be used in the library itself:
For example,
warnings.catch_warnings
because of python/cpython#73858.On the other hand, I would like to block using
numpy.random
in tests but allow in the library and/or examples (as it leads to random test failure).If you think it is useful, I could try to contribute (learning rust).
The text was updated successfully, but these errors were encountered: