Bug - glob exceptions from base config do not get overwritten by more specific local ones
See original GitHub issueI have a base config with has an exception with globs to activate specific flake8 plugins for test files only and deactivate other rules:
...
[tool.flakeheaven.exceptions."**/test_*.py"]
flake8-aaa = ["+*"]
flake8-bandit = ["-S101"]
In a project I set this file as base
and add another exception which is specific to a single file:
[tool.flakeheaven.exceptions."tests/test_rstcheck.py"]
flake8-aaa = ["-AAA01"]
But I still get multiple errors from this file like this:
tests/test_rstcheck.py:503:5: AAA01 no Act block found in test [flake8-aaa]
EDIT: I use the latest release version. EDIT2: On master this is also the case. 6138285ed808c334c9cb175e2a1f97dfb3cb679a
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:9
Top Results From Across the Web
Configuration Files - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >Your local changes to the following files would be overwritten ...
Your error appears when you have modified a file and the branch that you are switching to has changes for this file ...
Read more >git-config Documentation - Git
A list of all available configuration variables can be obtained using the git help --config command. OPTIONS. --replace-all. Default behavior is to replace...
Read more >Configuration — Kedro 0.18.4 documentation - Read the Docs
Kedro-specific configuration (e.g., DataCatalog configuration for IO) is loaded ... keys from conf/base will be overwritten by the ones from conf/local .
Read more >Configuration options | Yarn - Package Manager
List of all the configuration option for Yarn (yarnrc files)
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I looked a bit more into it and found when it was changed: https://github.com/life4/flakehell/pull/104
So, yeah, my initial guess is correct. I implemented it to return the first match and then there was merging logic added which basically inverted the priorities. Now you can either revert the change or reverse the whole logic inside. Namely:
Shame on me for bad test coverage. Flakehell was my first experiment on “deliver fast, test later if people start using it”. TBH, in flake8-ruler I just dropped exceptions logic, “keep it simple”.
Then IMO this should be changed. Lets make an experiment:
Setup
Lets assume we have the following file structure.
File tree:
This means we have two files:
root/dir_1/dir_1_1/file_1.py
root/dir_1/dir_1_2/file_2.py
Example prefix
When we have the following exceptions:
This would result in
+AAA01
for both files, because the upper exception has a shorter prefix. If I would see this config without knowledge I would assume thatfile_2.py
has-AAA01
andfile_1.py
has+AAA01
, would you not?Example glob
When we have the following exceptions:
This would again result in
+AAA01
for both files, because the upper exception has a shorter glob. If I would see this config without knowledge I would again assume thatfile_2.py
has-AAA01
andfile_1.py
has+AAA01
, would you not?Example prefix vs glob
When we have the following exceptions:
This would again result in
+AAA01
for both files, because the upper exception has is a glob even so it matches less good forfile_2.py
. If I would see this config without knowledge I would again assume thatfile_2.py
has-AAA01
andfile_1.py
has+AAA01
, would you not?Conclusion
So in all three cases the result is against intuition.
I think it would be better to take the longest matching prefix/glob instead of the shortest, because elsewise you cannot overwrite deeper nested exceptions.
I also think it is no good to let globs take precedence over prefixes by default.
If I have an error in my thought experiment please tell me.