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

ryecharm run ruff on rst file #5

Closed
trim21 opened this issue Sep 19, 2024 · 15 comments · Fixed by #6
Closed

ryecharm run ruff on rst file #5

trim21 opened this issue Sep 19, 2024 · 15 comments · Fixed by #6
Assignees
Labels
bug Something isn't working

Comments

@trim21
Copy link

trim21 commented Sep 19, 2024

What happened?

ryecharm run ruff on rst file and report syntax error

image

looks like it run ruff on rst file directly ruff check .\docs\enum.rst

image

image

Steps to reproduce

create a rst file and open it with ryecharm plugin

Relevant log output or stack trace

No response

Operating system

None

@trim21 trim21 added the bug Something isn't working label Sep 19, 2024
@InSyncWithFoo
Copy link
Owner

I'm afraid I can't reproduce the problem in any running mode.

What are your settings? Have you tried restarting the IDE and/or your computer?

If restarting doesn't work, could you check the logs (Ctrl + Shift + AShow Log in Explorer) and let me see its content? An email is fine if you don't want to post it publicly: <myusername>@gmail.com.

@trim21
Copy link
Author

trim21 commented Sep 19, 2024

image

@trim21
Copy link
Author

trim21 commented Sep 19, 2024

2024-09-20 02:26:05,989 [94317252]   INFO - #c.i.a.o.PathMacrosImpl - Saved path macros: {}
2024-09-20 02:26:16,220 [94327483]   INFO - #insyncwithfoo.ryecharm.Command - Running: (C:\Users\Trim21\proj\python\transmission-rpc) C:\Users\Trim21\scoop\shims\ruff.exe check --no-fix --exit-zero --quiet - --output-format json --stdin-filename C:\Users\Trim21\proj\python\transmission-rpc\docs\client.rst
2024-09-20 02:26:16,274 [94327537]   INFO - #insyncwithfoo.ryecharm.Command - <long output content removed>

@trim21
Copy link
Author

trim21 commented Sep 19, 2024

my ruff config:

[tool.ruff]
target-version = "py38"
extend-exclude = ["docs"]
line-length = 120

[tool.ruff.lint]
select = [
    "B",
    "C",
    "E",
    "F",
    "G",
    "I",
    "N",
    "Q",
    "S",
    "W",
    "BLE",
    "EXE",
    "ICN",
    "INP",
    "ISC",
    "NPY",
    "PD",
    "PGH",
    "PIE",
    "PL",
    "PT",
    "PYI",
    "RET",
    "RSE",
    "RUF",
    "SIM",
    "SLF",
    "TCH",
    "TID",
    "TRY",
    "YTT",
    "UP",
    "FA100",
    "FA102"
]

extend-fixable = ['UP']

ignore = [
    'PLR0911',
    'INP001',
    'N806',
    'N802',
    'N803',
    'E501',
    'BLE001',
    'RUF002',
    'S301',
    'S314',
    'S101',
    'N815',
    'S104',
    'C901',
    'ISC003',
    'PLR0913',
    'RUF001',
    'SIM108',
    'TCH003',
    'RUF003',
    'RET504',
    'TCH001',
    'TRY300',
    'TRY003',
    'TRY201',
    'TRY301',
    'PLR0912',
    'PLR0915',
    'PLR2004',
    'PGH003',
]

@trim21
Copy link
Author

trim21 commented Sep 19, 2024

I'm not sure if this help, but I'm editing doc files in this git repo https://github.com/trim21/transmission-rpc

@InSyncWithFoo
Copy link
Owner

InSyncWithFoo commented Sep 19, 2024

Thanks. I can reproduce it now.

Unbelievable as it is, RyeCharm is working correctly. It is supposed to run Ruff on any Python file; a file is considered a Python file if it passes at least one of the following two criteria:

I always thought PyFile is reserved for, well, Python files (and injected Python fragments). I was wrong.

The annotator was indeed passed a PyFile. However, this PSI file seems to be used only as the host for the actual, injected .rst PSI file (and injected files are not passed to annotators). Regardless, the PyFile in question is still linked to your .rst file, text and all; its .language is also the same as that of normal Python files. I have no idea why this is even the case.

I'll add an extra check, but this is more of a design bug on PyCharm's side (see also PY-73814).

@trim21
Copy link
Author

trim21 commented Sep 19, 2024

I'll add an extra check, but this is more of a design bug on PyCharm's side.

At least ruff extend-exclude should work, docs directory is already excluded in ruff config.

https://github.com/trim21/transmission-rpc/blob/a672599ad7e973bdf399393b4f3d0bd0c13064dd/pyproject.toml#L78

@InSyncWithFoo
Copy link
Owner

InSyncWithFoo commented Sep 19, 2024

At least ruff extend-exclude should work

The file's content is passed via standard input (note the - in the command). I might have to reconsider this decision if it proves to be too confusing. Note that letting Ruff reads the file itself isn't without its problems either: I would have to save the file beforehand.

Anyway, try the build out and let me know if it works.

@trim21
Copy link
Author

trim21 commented Sep 19, 2024

I think it works

@trim21
Copy link
Author

trim21 commented Sep 19, 2024

Ruff reads the file itself

ruff will ignore exclude config if it's called with ruff check /path/to/file

@trim21
Copy link
Author

trim21 commented Sep 19, 2024

I'm guessing the exclude config would work if I use LSP instead of cli?

@InSyncWithFoo
Copy link
Owner

I'm guessing the exclude config would work if I use LSP instead of cli?

Haven't rechecked, but that's probably correct.

@trim21
Copy link
Author

trim21 commented Sep 19, 2024

Yes files get excluded as expected in LSP mode.

@InSyncWithFoo
Copy link
Owner

I suppose this issue is solved then. If nothing changes I'll merge the fix tomorrow.

@trim21
Copy link
Author

trim21 commented Sep 19, 2024

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants