Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E704 false positives with one line overload def #1921

Closed
peterjc opened this issue Mar 7, 2024 · 2 comments
Closed

E704 false positives with one line overload def #1921

peterjc opened this issue Mar 7, 2024 · 2 comments

Comments

@peterjc
Copy link
Contributor

peterjc commented Mar 7, 2024

how did you install flake8?

$ pip install -U flake8

unmodified output of flake8 --bug-report

$ flake8 --bug-report
{
  "platform": {
    "python_implementation": "CPython",
    "python_version": "3.10.12",
    "system": "Linux"
  },
  "plugins": [
    {
      "plugin": "flake8-docstrings",
      "version": "1.7.0"
    },
    {
      "plugin": "mccabe",
      "version": "0.7.0"
    },
    {
      "plugin": "pycodestyle",
      "version": "2.11.1"
    },
    {
      "plugin": "pyflakes",
      "version": "3.2.0"
    }
  ],
  "version": "7.0.0"
}

describe the problem

what I expected to happen

This is a test case based on the one in #1575, but formatted with black 24.2.0 which uses a one-line def for the overload type annotation entries:

sample code

# test_case.py
from beartype.typing import Optional, Union, overload

from typing import overload


@overload
def foo() -> None: ...


@overload
def foo(arg: str) -> str: ...


@overload
def foo(arg: int, other_arg: Optional[int]) -> float: ...


def foo(
    arg: Optional[Union[int, str]] = None, other_arg: Optional[int] = None
) -> Optional[Union[float, str]]:
    if arg is None or isinstance(arg, str):
        return arg
    elif isinstance(arg, int) and isinstance(other_arg, int):
        return arg / other_arg
    else:
        assert False, f"unknown type(s) for {arg} and {other_arg}"

commands ran

$ flake8 --select E704 test_case.py
test_case.py:8:1: E704 multiple statements on one line (def)
test_case.py:12:1: E704 multiple statements on one line (def)
test_case.py:16:1: E704 multiple statements on one line (def)

I believe all three E704 entries are false positives, and should be special cased for the combination of @overload and elipsis.

@sigmavirus24
Copy link
Member

Flake8 orchestrates tools that implement checks. Please re-read the issue template and report this to the appropriate tool

@sigmavirus24 sigmavirus24 closed this as not planned Won't fix, can't repro, duplicate, stale Mar 7, 2024
@peterjc
Copy link
Contributor Author

peterjc commented Mar 7, 2024

Sigh. Found the right home: PyCQA/pycodestyle#1036

Suggestion to clarify the error code sources: #1922

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants