question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BUG: `pycodestyle` in `pyproject.toml` even though the plugin is disabled through the config

See original GitHub issue

Checklist

  • Same issue occurs when reproducing the MWE below: new virtualenv, clean folder, minimal additional libs, etc.
  • Same issue occurs when running without cache (eg by setting the env var FLAKEHEAVEN_CACHE_TIMEOUT=0)

Bug Description

Disabling pycodestyle warnings for pyproject.toml does not work when adding the file as an argument in the cli. Enabling pytest-mypy-plugins to lint toml files is therefore not possible. If I understand this correctly, according to the docs it should be possible to enable/disable plugins for specific files/paths.

Add this config to pyproject.toml to not lint pycodestyle on this file:

[tool.flakeheaven.exceptions."pyproject.toml"]
pycodestyle = ["-*"]

Executing flakeheaven lint pyproject.toml show this warning:

pyproject.toml
     3:   2 E999 SyntaxError: cannot assign to expression here. Maybe you meant '==' instead of '='? [pycodestyle]

Expected behavior

No pycodestyle warnings should show up.

Bug Repro

In short (if you have hatch installed):

  • execute hatch new test-flakeheaven test-flakeheaven
  • add flakeheaven to pyproject.toml under dependencies
  • add config to ignore pycodestyle in pyproject.toml (see below)
  • execute hatch run flakeheaven lint pyproject.toml
  1. Ubuntu 22.04
  2. python --version: 3.10.6
  3. pyproject.toml (and / or all other config files that apply, eg .pylintrc, stc)
[tool.flakeheaven]
exclude = [".git", "__pycache__", "venv/", "temp/"]
format = "grouped"

[tool.flakeheaven.exceptions."pyproject.toml"]
# or [tool.flakeheaven.exceptions."**/pyproject.toml"]
pycodestyle = ["-*"]
  1. flakeheaven plugins: pycodestyle and pyflakes (disabled)
  2. Contents of any additional files (eg sample .py file(s) to be linted): just a normal toml file
  3. [If available] contents of flakeheaven config -vvv

Steps to reproduce the behavior:

  1. run flakeheaven lint pyproject.toml

My suspicion is that there’s something wrong with the file/path matcher. If there’s tool.flakeheaven.exceptions like so **/foo.py, it will only match files in subdirectories, not at the first/root level.


This was an error on my side. Please ignore.

Additional test case:

Add a file foo.py to root and a subdirectory with the content a = 'bar' (single quotes!). Add an exception to pyproject.toml:

[tool.flakeheaven.exceptions."**/foo.py"]
flake8-black = ["-*"]

flakeheaven will still report:

foo.py
     1:   5 BLK100 Black would make changes. [flake8-black]

But nothing on subdir/foo.py.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
pwoolvettcommented, Oct 26, 2022

There’s a difference in flakeheaven between actually running the plugin and running it but not report some exceptions.

Instead, we could do if '-*' in rules. In this case, enabling a plugin globally in the plugins section (eg pycodestyle = ['+*']), and then disabling its execution explicitly in the exceptions with pycodestyle = ['-*'] would avoid even processing the file

1reaction
pwoolvettcommented, Oct 26, 2022

Im checking to understand whats going on.

The additional test case works as expected:

$ FLAKEHEAVEN_CACHE_TIMEOUT=0 flakeheaven lint subdir/foo.py
(no output, exit code zero)

then, after commenting out the flake8-black exception:

$ FLAKEHEAVEN_CACHE_TIMEOUT=0 flakeheaven lint subdir/foo.py 

subdir/foo.py
     1:   5 BLK100 Black would make changes. [flake8-black]
Read more comments on GitHub >

github_iconTop Results From Across the Web

[Bug] pyproject.toml in a plugin depending on ... - GitHub
In a plugin (e.g. OctoPrint-FixCBDFirmware) move black.toml to pyproject.toml and adjust the pre-commit config so the black run no longer ...
Read more >
Config — FlakeHell 0.8.0 documentation
By default, FlakeHell runs only pyflakes and pycodestyle. Modern and beautiful FlakeHell's config in pyproject.toml. Here you can configure everything for ...
Read more >
Introduction — pycodestyle 2.10.0 documentation
pycodestyle is a tool to check your Python code against some of the style conventions in PEP 8. Features; Disclaimer; Installation; Example usage...
Read more >
pyproject.toml · master · PAGoDA / Tools / MKDocs Template
Template to easily setup and managed mkdocs documentation in folder to have homogenous documentation. This repo hosts mkdocs configuration ...
Read more >
flake8_ruler - PyPI
Predefined configs for bugs, security, styleguides. Getting started. Install: python3 -m pip install flake8-ruler. Create pyproject.toml : # you ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found