wemake-services / wemake-python-styleguide

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

Port `flake-commas` #2641

Open Day0Dreamer opened 1 year ago

Day0Dreamer commented 1 year ago

https://github.com/PyCQA/flake8-commas is now read-only. It would be a good idea to include their code to our project, because we rely on it.

sobolevn commented 1 year ago

I've changed your issue to be a completely different one, because github is broken and I cannot post new issues for some reason.

bmakan commented 1 year ago

I've just updated to Python 3.12 and flake8 is crashing due to error in flake8-commas. I'll just uninstall it, but it's possibly a blocker for adding python3.12 support.

Edit: I have since reinitialized venv and the error did not reoccur. Maybe I just missed something the first time.

VelikiiNehochuha commented 8 months ago

same here, I've got the error.

python3.12

pip install wemake-python-styleguide==0.18.0
(venv) ➜  flake8_bug pip freeze
astor==0.8.1
attrs==23.2.0
bandit==1.7.7
darglint==1.8.1
docutils==0.20.1
eradicate==2.3.0
flake8==7.0.0
flake8-bandit==4.1.1
flake8-broken-line==1.0.0
flake8-bugbear==23.12.2
flake8-commas==2.1.0
flake8-comprehensions==3.14.0
flake8-debugger==4.1.2
flake8-docstrings==1.7.0
flake8-eradicate==1.5.0
flake8-isort==6.1.1
flake8-quotes==3.4.0
flake8-rst-docstrings==0.3.0
flake8-string-format==0.3.0
isort==5.13.2
markdown-it-py==3.0.0
mccabe==0.7.0
mdurl==0.1.2
pbr==6.0.0
pep8-naming==0.13.3
pycodestyle==2.11.1
pydocstyle==6.3.0
pyflakes==3.2.0
Pygments==2.17.2
PyYAML==6.0.1
restructuredtext_lint==1.4.0
rich==13.7.0
setuptools==69.1.0
snowballstemmer==2.2.0
stevedore==5.1.0
typing_extensions==4.9.0
wemake-python-styleguide==0.18.0
BLANK = ""
hashmap = {}

def replace_blank_labels(labels: list[str]) -> list[str]:
    for index, label in enumerate(labels):
        if label == BLANK:
            label = hashmap[index]
            hashmap[index] = f"[blank][{label}]"
        else:
            label = hashmap[index]
            hashma[index] = f"[label]{label}]"
Unable to find qualified name for module: sample.py
Traceback (most recent call last):
  File "/Users/vn/venv/bin/flake8", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/vn/venv/lib/python3.12/site-packages/flake8/main/cli.py", line 23, in main
    app.run(argv)
  File "/Users/vn/venv/lib/python3.12/site-packages/flake8/main/application.py", line 198, in run
    self._run(argv)
  File "/Users/vn/venv/lib/python3.12/site-packages/flake8/main/application.py", line 187, in _run
    self.run_checks()
  File "/Users/vn/venv/lib/python3.12/site-packages/flake8/main/application.py", line 103, in run_checks
    self.file_checker_manager.run()
  File "/Users/vn/venv/lib/python3.12/site-packages/flake8/checker.py", line 238, in run
    self.run_serial()
  File "/Users/vn/venv/lib/python3.12/site-packages/flake8/checker.py", line 221, in run_serial
    ).run_checks()
      ^^^^^^^^^^^^
  File "/Users/vn/venv/lib/python3.12/site-packages/flake8/checker.py", line 526, in run_checks
    self.run_ast_checks()
  File "/Users/vn/venv/lib/python3.12/site-packages/flake8/checker.py", line 428, in run_ast_checks
    for line_number, offset, text, _ in runner:
  File "/Users/vn/venv/lib/python3.12/site-packages/flake8_commas/_base.py", line 333, in run
    for error in get_comma_errors(tokens):
  File "/Users/vn/venv/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

it works fine with python3.11