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

False positive invalid-repr-returned with @overload #7624

Closed
MarcoGorelli opened this issue Oct 15, 2022 · 1 comment
Closed

False positive invalid-repr-returned with @overload #7624

MarcoGorelli opened this issue Oct 15, 2022 · 1 comment
Labels
Duplicate 🐫 Duplicate of an already existing issue False Positive 🦟 A message is emitted but nothing is wrong with the code Needs PR This issue is accepted, sufficiently specified and now needs an implementation

Comments

@MarcoGorelli
Copy link
Contributor

MarcoGorelli commented Oct 15, 2022

Bug description

from __future__ import annotations

from typing import overload

class Foo:
    def __repr__(self) -> str:
        return self.foo()

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

    def foo(self) -> str:
        return 'foo'

Configuration

No response

Command used

I just put the above in a file f.py and ran

pylint --disable all --enable invalid-repr-returned f.py

Pylint output

************* Module f
f.py:6:4: E0306: __repr__ does not return str (invalid-repr-returned)

-------------------------------------------------------------------
Your code has been rated at 4.44/10 (previous run: 10.00/10, -5.56)

Expected behavior

I don't think this should raise

Pylint version

pylint 2.15.4
astroid 2.12.11
Python 3.8.13 | packaged by conda-forge | (default, Mar 25 2022, 06:04:10) 
[GCC 10.3.0]

OS / Environment

Ubuntu (via WSL2)

Additional dependencies

No response

@MarcoGorelli MarcoGorelli added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Oct 15, 2022
@Pierre-Sassoulas Pierre-Sassoulas added False Positive 🦟 A message is emitted but nothing is wrong with the code Needs PR This issue is accepted, sufficiently specified and now needs an implementation and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Oct 15, 2022
@Pierre-Sassoulas Pierre-Sassoulas changed the title BUG: overload throws off invalid-repr-returned False positive invalid-repr-returned with overload Oct 15, 2022
@Pierre-Sassoulas Pierre-Sassoulas changed the title False positive invalid-repr-returned with overload False positive invalid-repr-returned with @overload Oct 15, 2022
@jacobtylerwalls
Copy link
Member

Thanks for the report.

@Pierre-Sassoulas I suggest closing as a likely duplicate of pylint-dev/astroid#1015 as long as we note this test case for pylint.

@Pierre-Sassoulas Pierre-Sassoulas closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
@Pierre-Sassoulas Pierre-Sassoulas added the Duplicate 🐫 Duplicate of an already existing issue label Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate 🐫 Duplicate of an already existing issue False Positive 🦟 A message is emitted but nothing is wrong with the code Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Projects
None yet
Development

No branches or pull requests

3 participants