Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This shrinks our flake8 error ignore config to a more reasonable level. Most error codes are irrelevant since they concern formatting which is handled by black, nowadays. However, there are two error codes in particular which triggered me doing this.
F841: local variable is assigned to but never used
This is an error code which detects assigned variables if they are unused. While this is usually not a big deal for tests (although not desired), this can be a frequent source for bugs in the actual code.
An example in this PR are changes in distributed/profile.py which likely indicates that we lost something at some point in time or distributed/scheduler.py l 3820ff which is definitely a bug (not fixed, yet)
We can still ignore this for tests, which is now reflected in the setup.cfg
F811 Redefinition of unused name from line n
This warning is raised if we are redefining symbols, e.g. functions or global variables, etc. Mostly, this is harmless. However, for test suites in particular this causes the problem of allowing duplicate test function names. I found 5-10 tests which were duplicated and therefore the first definition was ignored. These are typically cases where the definition of the two functions is hundreds or thousands of lines apart and it is impossible for reviewers to detect something like this. All instances where I found something like this, I simply appended a
_2
to the function name or similar.Enabling this error code in particular caused most of the change in this PR since every fixture import we were doing would trigger this, e.g. the following would raise a warning in line 3 because loop was redefined in the local scope although it was already defined in global scope but remains unused.
The easy solution to this is to use pytests fixture collection system via
conftest.py
which is why I added one import there to make all fixtures available to all functions. pytest will figure out the rest.