Skip to content
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

ruff doesn't work when I rename'xxx.PY' to 'xxx.py' #574

Open
Zander-1024 opened this issue Aug 7, 2024 · 10 comments
Open

ruff doesn't work when I rename'xxx.PY' to 'xxx.py' #574

Zander-1024 opened this issue Aug 7, 2024 · 10 comments
Labels
needs-mre Needs more information for reproduction

Comments

@Zander-1024
Copy link

I have another file that says xxx.PY in the name. When I found the problem, I changed it to xxx.py. At this point I found that the format didn't work.
When I change the file name or the extension, I find that it can be formatted normally again.

However, when the file is modified to xxx.py, it does not take effect. Finally, I find that the URI still points to xxx.PY. However, when I modify the file to xxx.PY again, the file still cannot be formatted.

Is there a cache for this? When I restarted the computer, the problem persisted.

2024-08-07 16:21:04.415 [info] Params: {
    "textDocument": {
        "uri": "file:///d%3A/*/xxx.PY"
    }
}

Ruff v2024.36.0

@dhruvmanila
Copy link
Member

Can you provide a way to reproduce this? The log message that you've provided is the request payload sent by VS Code.

When I change the file name or the extension, I find that it can be formatted normally again.

How are you running the formatter? And, how are you renaming the file? Is it from the command-line or by right-clicking the filename in VS Code and selecting the "Rename" option?

At least on Mac, VS Code seems to not care about whether it's uppercase or lowercase as I see that the payload always contains .py extension.

@Zander-1024
Copy link
Author

Can you provide a way to reproduce this? The log message that you've provided is the request payload sent by VS Code.

When I change the file name or the extension, I find that it can be formatted normally again.

How are you running the formatter? And, how are you renaming the file? Is it from the command-line or by right-clicking the filename in VS Code and selecting the "Rename" option?

At least on Mac, VS Code seems to not care about whether it's uppercase or lowercase as I see that the payload always contains .py extension.

system is windows10 , renaming is done by clicking on the file, when it's editable, formatting is done by right-clicking and selecting from the menu, and ruff turns on native server mode. I tried again, and as long as the suffix was written as PY and changed from PY to py, the file would have problems.

@Zander-1024
Copy link
Author

ruff-lsp doesn't seem to have this problem

@dhruvmanila
Copy link
Member

system is windows10 , renaming is done by clicking on the file, when it's editable, formatting is done by right-clicking and selecting from the menu, and ruff turns on native server mode. I tried again, and as long as the suffix was written as PY and changed from PY to py, the file would have problems.

Is it possible for you to record a video doing this and send it? I'm not able to follow how is the renaming being done and which option is selected for the formatting. Can you also provide the verbose logs by setting "ruff.trace.server": "verbose"?

@dhruvmanila dhruvmanila added the needs-mre Needs more information for reproduction label Aug 8, 2024
@Zander-1024
Copy link
Author

ruff_log.txt
The problem only occurs in native server mode, I switched computers and it's still happening!

@charliermarsh
Copy link
Member

Windows is case-insensitive, maybe related.

@dhruvmanila
Copy link
Member

@Zander-1024 Have you changed the case-sensitivity setting for the file system? (https://learn.microsoft.com/en-us/windows/wsl/case-sensitivity#modify-case-sensitivity).

@Zander-1024
Copy link
Author

I checked and it is disabled, maybe I need to turn it on. When I only change the case of the suffix, the uri doesn't change, so rust can't recognize the file properly, causing this problem! ruff-lsp doesn't have this problem because it doesn't read the file directly?

@dhruvmanila
Copy link
Member

If it's disabled then foo.py == foo.PY should be true, I think.

Can you send me your VS Code settings? Do you see this happening in other Python extension like vscode-flake8 or vscode-black-formatter, etc.?

@Zander-1024
Copy link
Author

settings.json

[tool.ruff]
# Exclude a variety of commonly ignored directories.
exclude = [
    ".bzr",
    ".direnv",
    ".eggs",
    ".git",
    ".git-rewrite",
    ".hg",
    ".mypy_cache",
    ".nox",
    ".pants.d",
    ".pytype",
    ".ruff_cache",
    ".svn",
    ".tox",
    ".venv",
    "__pypackages__",
    "_build",
    "buck-out",
    "build",
    "dist",
    "node_modules",
    "venv",
	"test",
	"proto",
]

# Same as Black.
line-length = 120
indent-width = 4

extend-include = ["*.ipynb"]

# Assume Python 3.8
target-version = "py310"

[tool.ruff.lint]
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`)  codes by default.
select = ["E", "F", "B"]
ignore = ["E501","B905"]

# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

[tool.ruff.format]
# Like Black, use double quotes for strings.
quote-style = "double"

# Like Black, indent with spaces, rather than tabs.
indent-style = "space"

# Like Black, respect magic trailing commas.
skip-magic-trailing-comma = false

# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-mre Needs more information for reproduction
Projects
None yet
Development

No branches or pull requests

3 participants