wemake-services / wemake-python-styleguide

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

False Positive WPS316 Parenthesized context managers #2415

Open mazlum opened 2 years ago

mazlum commented 2 years ago

What's wrong

WPS316 does not support Parenthesized context manager.

WPS316 Found context manager with too many assignments

filename1, filename2 = '/tmp/f1.txt', '/tmp/f2.txt'

with (
        open(filename1, "r") as file1, 
        open(filename2, 'r') as file2
):
    print(file1.readlines() == file2.readlines())

How it should be

It should be supported.

Flake8 version and plugins

{ "dependencies": [], "platform": { "python_implementation": "CPython", "python_version": "3.10.4", "system": "Darwin" }, "plugins": [ { "is_local": false, "plugin": "flake8-bandit", "version": "2.1.2" }, { "is_local": false, "plugin": "flake8-blind-except", "version": "0.2.1" }, { "is_local": false, "plugin": "flake8-broken-line", "version": "0.4.0" }, { "is_local": false, "plugin": "flake8-bugbear", "version": "22.4.25" }, { "is_local": false, "plugin": "flake8-comprehensions", "version": "3.9.0" }, { "is_local": false, "plugin": "flake8-darglint", "version": "1.8.1" }, { "is_local": false, "plugin": "flake8-debugger", "version": "4.1.2" }, { "is_local": false, "plugin": "flake8-docstrings", "version": "1.6.0, pydocstyle: 6.1.1" }, { "is_local": false, "plugin": "flake8-eradicate", "version": "1.2.1" }, { "is_local": false, "plugin": "flake8-pytest-style", "version": "1.6.0" }, { "is_local": false, "plugin": "flake8-string-format", "version": "0.3.0" }, { "is_local": false, "plugin": "flake8_builtins", "version": "1.5.2" }, { "is_local": false, "plugin": "flake8_commas", "version": "2.1.0" }, { "is_local": false, "plugin": "flake8_isort", "version": "4.1.1" }, { "is_local": false, "plugin": "flake8_quotes", "version": "3.3.1" }, { "is_local": false, "plugin": "logging-format", "version": "0.6.0" }, { "is_local": false, "plugin": "mccabe", "version": "0.6.1" }, { "is_local": false, "plugin": "naming", "version": "0.12.1" }, { "is_local": false, "plugin": "pycodestyle", "version": "2.8.0" }, { "is_local": false, "plugin": "pyflakes", "version": "2.4.0" }, { "is_local": false, "plugin": "rst-docstrings", "version": "0.2.5" }, { "is_local": false, "plugin": "wemake_python_styleguide", "version": "0.16.1" } ], "version": "4.0.1" }

pip information

pip 22.0.4 flake8-4.0.1 wemake_python_styleguide-0.16.1

OS information

macos

jason0kenyon commented 1 year ago

I agree. I can try and work on this.

sobolevn commented 1 year ago

Agreed, this should be fixed. @jason0kenyon please, this would be very appreciated!