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

python-ruff problem with ignore-per-file extensions #2068

Open
3 of 6 tasks
twmr opened this issue Apr 2, 2024 · 0 comments
Open
3 of 6 tasks

python-ruff problem with ignore-per-file extensions #2068

twmr opened this issue Apr 2, 2024 · 0 comments

Comments

@twmr
Copy link

twmr commented Apr 2, 2024

Checklist

  • I have checked existing issues for potential duplicates before creating this one.
  • I have read the Troubleshooting guide.

Bug description

When the python-ruff checker is used in a buffer for which special ignore-rules apply (can be set via e.g. [lint.extend-per-file-ignores] in ruff.toml), these ignore-rules are not considered.

It seems as if this is due to the value of default-directory, which is used for running ruff.
When I run flycheck-compile on a python file in mypkg/ in my project, it shows that

ruff check --config /tmp/ruff-example/ruff.toml --output-format\=text --stdin-filename /tmp/ruff-example/mypkg/mymod.py - < /tmp/ruff-example/mypkg/mymod.py

is called in /tmp/ruff-example/mypkg.

My ruff.toml file exists in the project root: /tmp/ruff-example.

Since ruff is not called in the project-root, my special ignore extensions:

[lint.extend-per-file-ignores]
"__init__.py" = ["E402", "D104"]
"mypkg/*.py" = [
  "D100",
  "D101",
  "D102",
  "D103",
]

are not considered. Therefore, a D103 warning (missing docstring in public function) is reported by flycheck/python-ruff for every public function in mymod.py without a docstring.

Expected behavior

I expect that ruff specific settings in my project ruff.toml/pyproject.toml are not ignored.

System configuration

Syntax checkers for buffer mymod.py in python-ts-mode:

First checker to run:

  python-ruff
    - may enable:         yes
    - executable:         Found at /home/thomashisch/miniconda3/bin/ruff
    - configuration file: Found at "/tmp/ruff-example/ruff.toml"
    - next checkers:      python-mypy

Checkers that may run as part of the first checker's chain:

  python-mypy
    - may enable:         yes
    - may run:            t
    - executable:         Found at /home/thomashisch/micromamba/envs/py_secs/bin/mypy
    - configuration file: Not found

Checkers that could run if selected:

  python-pylint  select
    - may enable:         yes
    - executable:         Found at /home/thomashisch/micromamba/envs/py_secs/bin/python
    - configuration file: Found at "/home/thomashisch/.pylintrc"
    - `pylint' module:    Found at "/home/thomashisch/micromamba/envs/py_secs/lib/python3.12/site-packages/pylint/__init__.py"
    - next checkers:      python-mypy

  python-pycompile  select
    - may enable:    yes
    - executable:    Found at /home/thomashisch/miniconda3/bin/python3
    - next checkers: python-mypy

Checkers that are compatible with this mode, but will not run until properly configured:

  python-flake8 (automatically disabled) reset
    - may enable:         no
    - executable:         Found at /home/thomashisch/miniconda3/bin/python3
    - configuration file: Not found
    - `flake8' module:    Missing; sys.path is ['/home/thomashisch/miniconda3/lib/python311.zip', '/home/thomashisch/miniconda3/lib/python3.11', '/home/thomashisch/miniconda3/lib/python3.11/lib-dynload', '/home/thomashisch/.local/lib/python3.11/site-packages', '/home/thomashisch/miniconda3/lib/python3.11/site-packages', '/home/thomashisch/main/site_python']
    - next checkers:      python-pylint, python-mypy

  python-pyright (automatically disabled) reset
    - may enable: no
    - executable: Not found

Flycheck Mode is enabled. Use C-u C-c ! x to enable disabled checkers.

--------------------

Flycheck version: 20240317.606
Emacs version:    30.0.50
System:           x86_64-pc-linux-gnu
Window system:    x

Emacs configuration:

  • Plain Emacs / Custom configuration
  • Spacemacs
  • Doom Emacs
  • Other shared configuration

Additional notes

Add any other context about the problem here.

@twmr twmr added the kind: bug label Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant