Giter Club home page Giter Club logo

flake8-eradicate's Introduction

flake8-eradicate

wemake.services Build Status codecov Python Version PyPI version wemake-python-styleguide

flake8 plugin to find commented out (or so called "dead") code.

This is quite important for the project in a long run. Based on eradicate project.

Installation

pip install flake8-eradicate

It is also a valuable part of wemake-python-styleguide.

Usage

Run your flake8 checker as usual. Commented code should raise an error.

Example:

flake8 your_module.py

Options

  • --eradicate-aggressive to enable aggressive mode from eradicate, can lead to false positives
  • --eradicate-whitelist to overwrite the whitelist from eradicate (# separated list)
  • --eradicate-whitelist-extend to extend the whitelist from eradicate (# separated list)

Error codes

Error code Description
E800 Found commented out code

Output example

Here's how output looks like (we are using wemake formatter):

flake8-eradicate output

License

MIT.

flake8-eradicate's People

Contributors

alirezaroshanzamir avatar asottile avatar bagerard avatar cielquan avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar fu2re avatar g-as avatar ggguser avatar mkniewallner avatar sgaynetdinov avatar sobolevn avatar tbrlpld avatar trim21 avatar valignatev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

flake8-eradicate's Issues

Switch from pkg_resources to importlib.metadata

Is there any interest in switching the pkg_resources dependency to the stdlib importlib.mtetadata? This would allow removing the dependency on setuptools.

Since this is only available on python3.8+ it would require a new dependency on the backport package importlib_metadata for python3.7. It would also mean dropping support for python3.6 but that is already EOL since 2021-12-23.

I am happy to submit a PR for this.

Dependabot can't resolve your Python dependency files

Dependabot can't resolve your Python dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Creating virtualenv flake8-eradicate-G9eUaCDf-py3.8 in /home/dependabot/.cache/pypoetry/virtualenvs
Updating dependencies
Resolving dependencies...

[PackageNotFound]
Package flake8-docstrings (1.5.0) not found.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Remove <4.0 Python Requirement

Since flake8-eradicate uses ^3.8 for its Python version range, this requires downstream projects that use poetry to set <4.0 as an upper bound for Python. It would be great if the Python version range could be changed to >=3.8 so that the upper bound isn't propagated downstream.

Detects "# TODO: ..." as commented out code

And other similar annotations with the pattern "# LABEL: detail".

It appears to be mistaking a legitimate comment for code containing a variable with type annotation.

I don't think it's appropriate to have to noqa every TODO or FIXME (unless they break a rule from somewhere else, of course).

Maybe there could be a whitelist of common labels that won't get picked up as a variable?

Very slow on long lists

It takes ages to check a file with very long statement (for example https://github.com/WeblateOrg/language-data/blob/master/weblate_language_data/check_languages.py takes minute and half to check).

The problem seems to be in:

https://github.com/sobolevn/flake8-eradicate/blob/a9866301eb145be5b2f17ae58532b549d97c53a0/flake8_eradicate.py#L126-L129

The _tokens accumulate until the statement parsing is complete and flake8-eradicate checks all the tokens in the list for every line.

Dependabot can't resolve your Python dependency files

Dependabot can't resolve your Python dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Creating virtualenv flake8-eradicate-y7hI5Vvf-py3.8 in /home/dependabot/.cache/pypoetry/virtualenvs
Updating dependencies
Resolving dependencies...

[PackageNotFound]
Package flake8-docstrings (1.5.0) not found.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Black formatting flags as code

If you're in the unfortunate situation of having to deal with Black formatting, then this plugin catches the on/off markers as if they were code. Maybe just needs a specific whitelist for these 2 lines:

# fmt: off
# fmt: on

Content of f-string interpreted as commented code

Using flake8-eradicate==1.2.1
On CPython 3.9.13
With flake8==4.0.1
Using the following code as an example

class FooClass(SpamClass):
    def render_html(self) -> str:
        return f"""
        <div>
            <div>
                <h2>
                    spam content <bold>{self.foo.bar().car()}</bold> to <bold>foo</bold><br/>
                </h2>
                <i>
                    β€œSome quote.”
                    <br/>~Quote author
                <i/>
            <div>
            </div>
                <table>
                    <tbody>
                        <tr>
                            <td><bold>Foo foo</bold></td>
                            <td>{self.bar.foo}</td>
                        </tr>
                        <tr>
                            <td><bold>Bar foo</bold></td>
                            <td>{self.barbar.foo}</td>
                        </tr>
                        <tr>
                            <td><bold>Foo spam</bold></td>
                            <td>
                                <a href="https://service.com/spam/foo/bar/{self.foo.car}">
                                    #{self.foo.car}
                                <a/>
                            </td>
                        </tr>
                        <tr>
                            <td><bold>Spam bar</bold></td>
                            <td>{self.foo()}</td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
        """

Following snipped, line #{self.foo.car} generates an error Found commented out code flake8(E800)

<a href="https://service.com/spam/foo/bar/{self.foo.car}">
    #{self.foo.car}
<a/>

Which, of course, is not correct because we are not dealing with a comment here. Removing the # from the content makes the error disappear, however, this is not the solution.

Dependabot can't resolve your Python dependency files

Dependabot can't resolve your Python dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Creating virtualenv flake8-eradicate-aUESMVGG-py3.8 in /home/dependabot/.cache/pypoetry/virtualenvs
Updating dependencies
Resolving dependencies...

[PackageNotFound]
Package flake8-isort (2.9.0) not found.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Issue with flake8-noqa, flake8-eradicate and commented out code

Hello. I'm using flake8, flake8-noqa & flake8-eradicate. Until flake8-noqa==1.2.5 it worked fine, but now I encounter weird behaviour.

Python version

$ python --version
Python 3.9.10

Dependencies:
flake8==5.0.4
flake8-eradicate==1.4.0
flake8-noqa==1.2.9

Current behaviour

code.py

# a = 5
a = 7

flake8 run

$ flake8 code.py
code.py:1:1: E800 Found commented out code

code.py

# a = 5  # noqa: E800
a = 7

flake8 run

$ flake8 code.py
code.py:1:1: NQA102 "# noqa: E800" has no matching violations

Expected behaviour

code.py

# a = 5
a = 7

flake8 run

$ flake8 code.py
code.py:1:1: E800 Found commented out code

code.py

# a = 5  # noqa: E800
a = 7

flake8 run -- no error

$ flake8 code.py

I created the same issue in flake8-noqa repository but its author pointed out that the issue could be in your package.
Can you please take a look?

The "setuptools" requirement should be explicitly defined (ModuleNotFoundError: No module named 'pkg_resources').

Due to the usage of the "pkg_resources" module, the "setuptools" requirement should be explicitly defined (in this project, it is runtime requirement as well as installation time requirement). Because there are tools (such as Pants) that, after installing the library, do not maintain the installation time requirements, hence, this error is given:

ModuleNotFoundError: No module named 'pkg_resources'

which raises this exception on the Flake8:

flake8.exceptions.FailedToLoadPlugin: Flake8 failed to load plugin "E8" due to No module named 'pkg_resources'.

Dependabot can't resolve your Python dependency files

Dependabot can't resolve your Python dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Creating virtualenv flake8-eradicate-qqgUL50_-py3.8 in /home/dependabot/.cache/pypoetry/virtualenvs
Updating dependencies
Resolving dependencies...

[PackageNotFound]
Package flake8-docstrings (1.5.0) not found.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Commented out code not detected when code block is two lines long

This is a good one. If you paste the following code into a new file, flake8-eradicate will only detect the first and the third code blocks. The second block, split over two lines is not detected.


# create_output_path(*os.path.split(mypath),
#                    overwrite=overwrite,
#                    exist_ok=True)

# create_output_path(*os.path.split(mypath), overwrite=overwrite,
#                    exist_ok=True)

# create_output_path(*os.path.split(mypath), overwrite=overwrite, exist_ok=True)

Repro steps

$ python3.8 -m venv ~/deleteme
$ source ~/deleteme/bin/activate
$ pip install flake8-eradicate
$ flake8 test.py --max-line-length=81

Expected result

Commented out code found on lines 2-4, 6-7, and 9.

Actual result

test.py:3:1: E800 Found commented out code
test.py:9:1: E800 Found commented out code

Flake8 4.0.0

Flake8 4.x has been released, and since the dependency has been defined here at ^3.5, the update is currently impossible.

There hasn't been any API change, so bumping should be straightforward.

I can open a PR, provided some insight on if you want to keep compatibility with Flake8 3.x.

flake8-eradicate and black

Hi,

Thanks for the tool. Unfortunately, flake8-eradicate recognizes # fmt: on and # fmt: off as commented out code whereas the comments identify blocks which should not be formatted with black. Is it possible to exclude these patterns?

Best

Errors occurred with encoding hints that valid with PEP 263

Just FYI:

I get the following error message from flake8-eradicate via pylama:

sample.py:1:1: E800: Found commented out code: # encoding: utf-8 [eradicate]

I often use the following encoding hint:

# encoding: utf-8

And this style of encoding-hints is valid according to PEP 263.
valid encoding hints regular expression:

^[ \t\f]*#.*?coding[:=][ \t]*([-_.a-zA-Z0-9]+)

However, the current version of eradicate judged #encoding: utf-8 as a commented out code.
I try to modify the behavior to follow PEP 263 with PyCQA/eradicate#9 for now.

False Positives | Markdown in block strings

Hello the following code is now getting flagged as E800 Found commented out code
This has only just started getting flagged with the upgrade from 1.0.0 -> 1.1.0

Example code:

MARKDOWN = """
# {variable_containing_header_one}
Lots of content here...
"""

False-Positive E800 in multiline docstring based on content

$ flake8 --version
5.0.4 (flake8-eradicate: 1.4.0, mccabe: 0.7.0, pycodestyle: 2.9.1, pyflakes: 2.5.0) CPython 3.9.15 on Linux

Working Code:

"""
#
# Copyright (c) 2022. All rights reserved.
#
# Project:    Test project
# Created:    2022-09-23
#
# @package
# @subpackage
# @author
#
"""

Output:

$ flake8
$ echo $?
0

Failing Code (Only date changed):

"""
#
# Copyright (c) 2022. All rights reserved.
#
# Project:    Test project
# Created:    2022-11-23
#
# @package
# @subpackage
# @author
#
"""

Output:

$ flake8
./main.py:6:1: E800 Found commented out code
$ echo $?
1

same thing happens if project is changed to a single word (e.g. test-project). Seems to be somehow related to the colons after Project/Created, if I remove them the errors disappear.

Release master branch on PyPi

The current version of this plugin on PyPi (1.2.1) is not able to run with flake8's current version (5.0.1). This has been fixed in #262 but has not been updated on PyPi. Please could this be done?

Dependabot can't resolve your Python dependency files

Dependabot can't resolve your Python dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Creating virtualenv flake8-eradicate-hFfgc4DS-py3.8 in /home/dependabot/.cache/pypoetry/virtualenvs
Updating dependencies
Resolving dependencies...

[PackageNotFound]
Package flake8-docstrings (1.5.0) not found.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

--stdin-display-name causes FileNotFoundError or eradicating wrong content

It appears that the current logic for detecting stdin does not handle the case that flake8 is invoked with --stdin-display-name. For example:

echo 'print("Hello World!")' | flake8 --select E8 --stdin-display-name=nonexistent.py -

Will cause flake8 to die with output similar to the following:

Traceback (most recent call last):
  File "/path/to/project/.venv/bin/flake8", line 10, in <module>
    sys.exit(main())
  File "/path/to/project/.venv/lib/python3.7/site-packages/flake8/main/cli.py", line 18, in main
    app.run(argv)
  File "/path/to/project/.venv/lib/python3.7/site-packages/flake8/main/application.py", line 393, in run
    self._run(argv)
  File "/path/to/project/.venv/lib/python3.7/site-packages/flake8/main/application.py", line 381, in _run
    self.run_checks()
  File "/path/to/project/.venv/lib/python3.7/site-packages/flake8/main/application.py", line 300, in run_checks
    self.file_checker_manager.run()
  File "/path/to/project/.venv/lib/python3.7/site-packages/flake8/checker.py", line 332, in run
    self.run_serial()
  File "/path/to/project/.venv/lib/python3.7/site-packages/flake8/checker.py", line 316, in run_serial
    checker.run_checks()
  File "/path/to/project/.venv/lib/python3.7/site-packages/flake8/checker.py", line 616, in run_checks
    self.run_ast_checks()
  File "/path/to/project/.venv/lib/python3.7/site-packages/flake8/checker.py", line 512, in run_ast_checks
    for (line_number, offset, text, check) in runner:
  File "/path/to/project/.venv/lib/python3.7/site-packages/flake8_eradicate.py", line 88, in run
    fix_file(self.filename, options, buffer)
  File "/path/to/project/.venv/lib/python3.7/site-packages/eradicate.py", line 157, in fix_file
    encoding = detect_encoding(filename)
  File "/path/to/project/.venv/lib/python3.7/site-packages/eradicate.py", line 188, in detect_encoding
    with open(filename, 'rb') as input_file:
FileNotFoundError: [Errno 2] No such file or directory: 'nonexistent.py'

If nonexistent.py did exist, eradicate would check the old version rather than the version from stdin, which can be confusing for users.

I don't see an easy fix, since eradicate doesn't appear to have an API for passing file content from the lines argument. Working with the eradicate author to add one is probably ideal. Finding another way to detect whether flake8 is linting stdin and silently ignoring it is probably workable.

Cheers,
Kevin

P.S. Note: ALE passes --stdin-display-name to flake8, which is how I noticed the issue.

Installation doesn't pull in `attrs`

Running pipenv install --dev flake8-eradicate gives the error message listed below (using the ale syntax checker inside vim). Adding attrs to the end of the install stanza has the plugin work as expected so it looks like it's not listed as a dependency?

 Traceback (most recent call last):
   File "/Users/johno/.local/share/virtualenvs/glint_processor-GwxykaLr/lib/python3.6/site-packages/flake8/plugins/manager.py", line 178, in load_plugin
-    self._load(verify_requirements)
   File "/Users/johno/.local/share/virtualenvs/glint_processor-GwxykaLr/lib/python3.6/site-packages/flake8/plugins/manager.py", line 150, in _load
-    self._plugin = resolve()
   File "/Users/johno/.local/share/virtualenvs/glint_processor-GwxykaLr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2331, in resolve
-    module = __import__(self.module_name, fromlist=['__name__'], level=0)
   File "/Users/johno/.local/share/virtualenvs/glint_processor-GwxykaLr/lib/python3.6/site-packages/flake8_eradicate.py", line 6, in <module>
-    import attr
 ModuleNotFoundError: No module named 'attr'

 During handling of the above exception, another exception occurred:

 Traceback (most recent call last):
   File "/Users/johno/.local/share/virtualenvs/glint_processor-GwxykaLr/bin/flake8", line 11, in <module>
-    sys.exit(main())
   File "/Users/johno/.local/share/virtualenvs/glint_processor-GwxykaLr/lib/python3.6/site-packages/flake8/main/cli.py", line 16, in main
-    app.run(argv)
   File "/Users/johno/.local/share/virtualenvs/glint_processor-GwxykaLr/lib/python3.6/site-packages/flake8/main/application.py", line 396, in run
-    self._run(argv)
   File "/Users/johno/.local/share/virtualenvs/glint_processor-GwxykaLr/lib/python3.6/site-packages/flake8/main/application.py", line 383, in _run
-    self.initialize(argv)
   File "/Users/johno/.local/share/virtualenvs/glint_processor-GwxykaLr/lib/python3.6/site-packages/flake8/main/application.py", line 365, in initialize
-    self.find_plugins()
   File "/Users/johno/.local/share/virtualenvs/glint_processor-GwxykaLr/lib/python3.6/site-packages/flake8/main/application.py", line 191, in find_plugins
-    self.check_plugins.load_plugins()
   File "/Users/johno/.local/share/virtualenvs/glint_processor-GwxykaLr/lib/python3.6/site-packages/flake8/plugins/manager.py", line 423, in load_plugins
-    plugins = list(self.manager.map(load_plugin))
   File "/Users/johno/.local/share/virtualenvs/glint_processor-GwxykaLr/lib/python3.6/site-packages/flake8/plugins/manager.py", line 311, in map
-    yield func(self.plugins[name], *args, **kwargs)
   File "/Users/johno/.local/share/virtualenvs/glint_processor-GwxykaLr/lib/python3.6/site-packages/flake8/plugins/manager.py", line 421, in load_plugin
-    return plugin.load_plugin()
   File "/Users/johno/.local/share/virtualenvs/glint_processor-GwxykaLr/lib/python3.6/site-packages/flake8/plugins/manager.py", line 186, in load_plugin
-    raise failed_to_load
 flake8.exceptions.FailedToLoadPlugin: Flake8 failed to load plugin "E8" due to No module named 'attr'.

Exception when running via pre-commit

Hi, I ran this on my project through pre-commit flake8 hook and got this exception:

Traceback (most recent call last):
File "/home/uri/.cache/pre-commit/repo7r732xof/py_env-python3.7/bin/flake8", line 10, in
sys.exit(main())
File "/home/uri/.cache/pre-commit/repo7r732xof/py_env-python3.7/lib/python3.7/site-packages/flake8/main/cli.py", line 22, in main
app.run(argv)
File "/home/uri/.cache/pre-commit/repo7r732xof/py_env-python3.7/lib/python3.7/site-packages/flake8/main/application.py", line 397, in run
self._run(argv)
File "/home/uri/.cache/pre-commit/repo7r732xof/py_env-python3.7/lib/python3.7/site-packages/flake8/main/application.py", line 384, in _run
self.initialize(argv)
File "/home/uri/.cache/pre-commit/repo7r732xof/py_env-python3.7/lib/python3.7/site-packages/flake8/main/application.py", line 368, in initialize
self.register_plugin_options()
File "/home/uri/.cache/pre-commit/repo7r732xof/py_env-python3.7/lib/python3.7/site-packages/flake8/main/application.py", line 209, in register_plugin_options
self.check_plugins.register_options(self.option_manager)
File "/home/uri/.cache/pre-commit/repo7r732xof/py_env-python3.7/lib/python3.7/site-packages/flake8/plugins/manager.py", line 490, in register_options
list(self.manager.map(register_and_enable))
File "/home/uri/.cache/pre-commit/repo7r732xof/py_env-python3.7/lib/python3.7/site-packages/flake8/plugins/manager.py", line 298, in map
yield func(self.plugins[name], *args, **kwargs)
File "/home/uri/.cache/pre-commit/repo7r732xof/py_env-python3.7/lib/python3.7/site-packages/flake8/plugins/manager.py", line 486, in register_and_enable
call_register_options(plugin)
File "/home/uri/.cache/pre-commit/repo7r732xof/py_env-python3.7/lib/python3.7/site-packages/flake8/plugins/manager.py", line 398, in generated_function
return method(optmanager, *args, **kwargs)
File "/home/uri/.cache/pre-commit/repo7r732xof/py_env-python3.7/lib/python3.7/site-packages/flake8/plugins/manager.py", line 217, in register_options
add_options(optmanager)
File "/home/uri/.cache/pre-commit/repo7r732xof/py_env-python3.7/lib/python3.7/site-packages/flake8_eradicate.py", line 67, in add_options
parse_from_config=True,
File "/home/uri/.cache/pre-commit/repo7r732xof/py_env-python3.7/lib/python3.7/site-packages/flake8/options/manager.py", line 395, in add_option
self._current_group.add_argument(*option_args, **option_kwargs)
File "/usr/lib/python3.7/argparse.py", line 1362, in add_argument
action = action_class(**kwargs)
TypeError: init() got an unexpected keyword argument 'type'

Dependabot can't resolve your Python dependency files

Dependabot can't resolve your Python dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Creating virtualenv flake8-eradicate-P_u_1v4p-py3.8 in /home/dependabot/.cache/pypoetry/virtualenvs
Updating dependencies
Resolving dependencies...

[PackageNotFound]
Package flake8-docstrings (1.5.0) not found.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Docs request: example setup.cfg

From #69 it looks like config files are supported.

Can you document how to add a setup.cfg entry for flake8-eradicate in the README.md? Specifically how to whitelist with eradicate-whitelist-extend.

--eradicate-whitelist-extend to extend the whitelist from eradicate (# separated list)

Also, what is a # separated list?


For example, I need to whitelist this line:

# Formula: (counts/distance) = (counts/step) (steps/turns) (turns/distance)

`noqa` comments are detect as code

This line raises an E800 warning.

# noqa: A100

These do not:

# noqa: 100
# noqa: something
# noqa: "Something"

If anything, the second block might be code (like a line of a multi-line dictionary definition). The first block is a valid noqa-comment and should not raise that warning.

False-positive on mypy related config

Hello!

I have the following mypy's configuration line at the top of my file:

# mypy: disable-error-code="attr-defined"

When I'm running flake8, I'm getting E800 error on this line. If I add noqa: E800, mypy is ignoring this config line. I've tried the following variations:

# mypy: disable-error-code="attr-defined" noqa: E800
# noqa: E800 mypy: disable-error-code="attr-defined" noqa: E800
noqa: E800
mypy: disable-error-code="attr-defined" noqa: E800

I figured out, that I can ignore E800 error for the whole file, but that does not seem as a good option. Is there a way to config all this, or does the plugin itself require some fix? Thank you!

I'm using flake8-eradicate==1.4.0 installed through wemake-python-styleguide.

Dependabot can't resolve your Python dependency files

Dependabot can't resolve your Python dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Creating virtualenv flake8-eradicate-dLuq8bld-py3.8 in /home/dependabot/.cache/pypoetry/virtualenvs
Updating dependencies
Resolving dependencies...

[PackageNotFound]
Package flake8-docstrings (1.5.0) not found.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

[Regression] `flake8-eradicate==1.0.0` conflicts with `wemake-python-styleguide` under GHA

I don't know if this is the right repo for this issue but my best guess is that it is.

I'm using pre-commit.com too and I have an upstream flake8 hook set up. I've added flake8-eradicate>=1.0.0 and wemake-python-styleguide there. That seemed to work fine in local envs of developers under different OSs.
But in GitHub Actions CI/CD something shady started happening, something quite unobvious and hard to debug. I suspected that some flake8 plugins misbehave but I had no idea which ones.

flake8 started failing with violations that were supposed to be ignored in the config. It wasn't really obvious in the CI because I used the wemake formatter and it somehow didn't show the error messages, only some lines from code.
Example: https://github.com/ansible/pylibssh/runs/1566735649?check_suite_focus=true#step:11:31

I had to break into those GHA runner VMs over SSH using https://github.com/marketplace/actions/debugging-with-tmate to gather more intel!
Commenting out #format = wemake revealed another unexpected detail β€” almost all of those error messages had error codes prefixed with a letter they weren't supposed to use β€” Z. Things like these came up:

tests/conftest.py:14:1: Z101 Found nested import "pylibsshext.session"
from pylibsshext.session import Session
^
tests/conftest.py:44:9: Z111 Found bare raise outside of except "raise"        raise
        ^
tests/conftest.py:122:9: Z110 Found wrong keyword "del"
        del ssh_session  # noqa: WPS420
        ^

I've commented out the flake8-eradicate>=1.0.0 line and it reported no violations when the version required by wemake-python-styleguide, which is flake8-eradicate (>=0.3,<0.4) (ref https://pypi.org/pypi/wemake-python-styleguide/json), was used.

I confirmed that when I tried to re-add flake8-eradicate>=1.0.0, it started throwing errors at me again. Then, I removed the wemake-python-styleguide line keeping flake8-eradicate>=1.0.0 in place and that worked too.

STR: fork https://github.com/ansible/pylibssh/tree/55b241a001c3621d68776f244a46650bfa5590f9, stick ansible/pylibssh@b4f27ea there and connect over SSH to see the env.

N.B. I have no clue why but it's only happening under the GitHub Actions VMs and not locally (checked under CPython 3.8 and 3.9).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.