wemake-services / wemake-python-styleguide

The strictest and most opinionated python linter ever!
https://wemake-python-styleguide.rtfd.io
MIT License
2.55k stars 378 forks source link

Drop the abandoned `flake8-commas` plugin from deps #2933

Open webknjaz opened 7 months ago

webknjaz commented 7 months ago

What's wrong

pre-commit.ci updated their default runtime to Python 3.12 yesterday and here's how this plugin crashes there:

multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/usr/lib/python3.12/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
                    ^^^^^^^^^^^^^^^^^^^
  File "/pc/clone/EVNAC1wjQUCuPU9hNlnoZQ/py_env-python3/lib/python3.12/site-packages/flake8/checker.py", line 83, in _mp_run
    ).run_checks()
      ^^^^^^^^^^^^
  File "/pc/clone/EVNAC1wjQUCuPU9hNlnoZQ/py_env-python3/lib/python3.12/site-packages/flake8/checker.py", line 526, in run_checks
    self.run_ast_checks()
  File "/pc/clone/EVNAC1wjQUCuPU9hNlnoZQ/py_env-python3/lib/python3.12/site-packages/flake8/checker.py", line 428, in run_ast_checks
    for line_number, offset, text, _ in runner:
  File "/pc/clone/EVNAC1wjQUCuPU9hNlnoZQ/py_env-python3/lib/python3.12/site-packages/flake8_commas/_base.py", line 333, in run
    for error in get_comma_errors(tokens):
  File "/pc/clone/EVNAC1wjQUCuPU9hNlnoZQ/py_env-python3/lib/python3.12/site-packages/flake8_commas/_base.py", line 306, in get_comma_errors
    (token.type == COLON and stack[-1].comma == LAMBDA_EXPR)
                             ~~~~~^^^^
IndexError: list index out of range
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/pc/clone/EVNAC1wjQUCuPU9hNlnoZQ/py_env-python3/bin/flake8", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/pc/clone/EVNAC1wjQUCuPU9hNlnoZQ/py_env-python3/lib/python3.12/site-packages/flake8/main/cli.py", line 23, in main
    app.run(argv)
  File "/pc/clone/EVNAC1wjQUCuPU9hNlnoZQ/py_env-python3/lib/python3.12/site-packages/flake8/main/application.py", line 198, in run
    self._run(argv)
  File "/pc/clone/EVNAC1wjQUCuPU9hNlnoZQ/py_env-python3/lib/python3.12/site-packages/flake8/main/application.py", line 187, in _run
    self.run_checks()
  File "/pc/clone/EVNAC1wjQUCuPU9hNlnoZQ/py_env-python3/lib/python3.12/site-packages/flake8/main/application.py", line 103, in run_checks
    self.file_checker_manager.run()
  File "/pc/clone/EVNAC1wjQUCuPU9hNlnoZQ/py_env-python3/lib/python3.12/site-packages/flake8/checker.py", line 236, in run
    self.run_parallel()
  File "/pc/clone/EVNAC1wjQUCuPU9hNlnoZQ/py_env-python3/lib/python3.12/site-packages/flake8/checker.py", line 205, in run_parallel
    self.results = list(pool.imap_unordered(_mp_run, self.filenames))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/multiprocessing/pool.py", line 873, in next
    raise value
IndexError: list index out of range

(https://results.pre-commit.ci/run/github/16620627/1713926290.3FtxdzwlRJKVVhqJTxjy7Q)

So this hinted me to go check that plugin's upstream only to find out that it was archived on Oct 14, 2021, with the "No Maintenance Intended" badge and a recommendation to use a formatter: https://github.com/PyCQA/flake8-commas#flake8-extension-to-enforce-better-comma-placement.

I use the suggested pre-commit fixer which already ensures that I have commas in all the right places so the plugin is redundant. However, it does not seem like there is a way to tell flake8 to skip loading it and WPS pulls it in unconditionally which results in a stalemate :man_shrugging:

Hence the $sbj.

How it should be

It shouldn't crash the entire flake8 run and be disablable.

Flake8 version and plugins

It's a bump from flake8 v4.0.1 to v7.0.0 combined with bumping WPS. See https://github.com/cherrypy/cheroot/commit/6f1e5b5eb32a0f923db9f532853952a5760517b2#diff-63a9c44a44acf85fea213a857769990937107cf072831e1a26808cfde9d096b9R146-R159.

pip information

N/A, it's only reproducible @ pre-commit.ci so far.

OS information

https://results.pre-commit.ci/run/github/16620627/1713926290.3FtxdzwlRJKVVhqJTxjy7Q says it's image ghcr.io/pre-commit-ci/runner-image:2024-04-23-b71d47a => 5754bdbf0070e1758fa1e47f7b043cd04c7f8bda1d93703ff17e704ffb89a09d and python@python3 in it.

sobolevn commented 7 months ago

Yes, I plan to switch to ruff for this kind of checks soon! 👍

webknjaz commented 7 months ago

Apparently, there's a fork https://pypi.org/project/flake8-commas-x/ that supports Python 3.12. And the fork's author was given maintenance privileges on the original thing last month: https://github.com/PyCQA/meta/issues/59. So maybe it'll get resurrected at some point.

Meanwhile, the dependency could be made conditional depending on the Python version and that should fix the incompatibility short-term.