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

function-redefined false positive with type hints #4936

Closed
MatthewScholefield opened this issue Aug 31, 2021 · 0 comments · Fixed by #4938
Closed

function-redefined false positive with type hints #4936

MatthewScholefield opened this issue Aug 31, 2021 · 0 comments · Fixed by #4938
Labels
Milestone

Comments

@MatthewScholefield
Copy link

Bug description

from typing import Callable
from functools import wraps

do_something: Callable[[], int]


def with_config(func):
    @wraps(func)
    def wrapper():
        return func("arg")
    return wrapper


@with_config
def do_something(arg: str) -> int:
    return len(arg)

Configuration

No response

Command used

pylint -E example.py

Pylint output

************* Module example
example.py:16:0: E0102: function already defined line 4 (function-redefined)

Expected behavior

No output; the function is not being redefined because the top instance is not a definition — it is a type declaration.

Pylint version

pylint 2.10.2
astroid 2.7.3
Python 3.9.5 (default, May 24 2021, 12:50:35) 
[GCC 11.1.0]

OS / Environment

No response

Additional dependencies

No response

@MatthewScholefield MatthewScholefield added Bug 🪲 Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Aug 31, 2021
DanielNoord added a commit to DanielNoord/pylint that referenced this issue Aug 31, 2021
@Pierre-Sassoulas Pierre-Sassoulas removed the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Aug 31, 2021
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.11.0 milestone Aug 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants