wemake-services / wemake-python-styleguide

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

False positive WPS319 #3055

Open KulykDmytro opened 1 month ago

KulykDmytro commented 1 month ago

What's wrong

using of master version causing false-positive WPS319 violation when using multiline strings in conjunction of function (dedent in our case)

def _insert_query(config: AWSTransformTaskGroup) -> str:
    columns = f"{{{{ athena.column_names('{config.database}', '{config.table}', include_partition_keys=True) }}}}"
    return dedent(f"""
        insert into {config.result_database}.{config.result_table} ({columns})
        select {columns} from {config.inc_database}.{config.inc_table}
    """)

Violation log:

  158:8    WPS319 Found bracket in wrong position
  return dedent(f"""
        insert into {config.result_database}.{config.result_table} ({columns})
        select {columns} from {config.inc_database}.{config.inc_table}
    """)
     ^

How it should be

should pass such expressions

Flake8 version and plugins

7.1.1 (darglint: 1.8.1, flake8-bandit: 4.1.1, flake8-broken-line: 1.0.0, flake8-bugbear: 24.8.19, flake8-commas: 4.0.0, flake8-comprehensions: 3.15.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, mccabe: 0.7.0, pep8-naming: 0.14.1, pycodestyle: 2.12.1, pyflakes: 3.2.0, wemake-python-styleguide: 0.19.2) CPython 3.12.0 on Linux

pip information

pip 24.2 from /usr/local/lib/python3.12/site-packages/pip (python 3.12)

OS information

Alpine Linux v3.17

sobolevn commented 1 month ago

It should be:

    return dedent(
        f"""
        insert into {config.result_database}.{config.result_table} ({columns})
        select {columns} from {config.inc_database}.{config.inc_table}
        """
    )

Please, try this :)