-
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
Audit how we determine whether a file is a "Python source file" #13691
Comments
Note: I think that depends on the file system's case sensitivity. Other than that. I think we should ignore casing when matching files because that's what most desktop environments to. They use the same application to open a |
Here, for example, we might want to continue to do case-sensitive matching, since the rule only applies to the names of Python modules that are intended to be importable by other Python modules: ruff/crates/ruff_linter/src/rules/pep8_naming/rules/invalid_module_name.rs Lines 51 to 59 in 5b4afd3
If a |
There's also this issue astral-sh/ruff-vscode#574 related to the server although not sure if this affects that. |
Fwiw mypy has some special handling in a few places to be case sensitive even on case insensitive file systems |
I noticed in #13682 that there's some inconsistency regarding how we determine whether a file is a "Python source file" currently. In the code for
ruff server
(and the red-knot port of the server), we take care to do case-insensitive matching when figuring out whether something is a notebook file or not:ruff/crates/ruff_server/src/session/index.rs
Lines 124 to 126 in 5b4afd3
ruff/crates/red_knot_server/src/session/index.rs
Lines 75 to 79 in 5b4afd3
Elsewhere, however, we mostly use case-sensitive matching:
ruff/crates/ruff_python_ast/src/lib.rs
Lines 91 to 101 in 5b4afd3
ruff/crates/red_knot_python_semantic/src/module_resolver/path.rs
Lines 41 to 60 in 5b4afd3
For places like the red-knot module resolver, it's likely correct to do case-sensitive matching (Python recognises
foo.py
as an importable module, but notfoo.PY
), but in other places it may not be. We should audit the code to make sure we're using case-sensitive matching and case-insensitive matching for file extensions in the correct places. We should also add comments to the places where there might be a subtle reason why case-(in)sensitive matching is required, rather than vice versa.The text was updated successfully, but these errors were encountered: