Skip to content

R0204: Redefinition of <name> type - False positive on async functions. #8120

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

Closed
benwah opened this issue Jan 27, 2023 · 2 comments · Fixed by #8123
Closed

R0204: Redefinition of <name> type - False positive on async functions. #8120

benwah opened this issue Jan 27, 2023 · 2 comments · Fixed by #8123
Assignees
Labels
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
Milestone

Comments

@benwah
Copy link

benwah commented Jan 27, 2023

Bug description

Issue was already identified here: #1279 - The issue was closed, but the bug is still there.

This will yield a false negative:

class Root:
    ...


class TestTest:
    async def test_one(self):
        potato = Root()
        assert potato

    async def test_two(self):
        potato = {}
        assert potato

Configuration

[tool.pylint.MASTER]
disable = [
    "C0114",
    "C0115",
    "C0116",
    "E0213",
    "R0801",
    "R0901",
    "R0911",
    "R0913",
    "R6103",
    "W0201",
    "W0238",
    "W0212",
    "W0613",
]
max-line-length = 88
extension-pkg-allow-list="pydantic"
min-public-methods = 0
default-docstring-type = "google"
string-quote="double"
triple-quote="double"
docstring-quote="double"
load-plugins = [
    "pylint.extensions.bad_builtin",
    "pylint.extensions.broad_try_clause",
    "pylint.extensions.check_elif",
    "pylint.extensions.code_style",
    "pylint.extensions.comparison_placement",
    "pylint.extensions.confusing_elif",
    "pylint.extensions.consider_ternary_expression",
    "pylint.extensions.docparams",
    "pylint.extensions.empty_comment",
    "pylint.extensions.eq_without_hash",
    "pylint.extensions.for_any_all",
    "pylint.extensions.overlapping_exceptions",
    "pylint.extensions.private_import",
    "pylint.extensions.redefined_variable_type",
    "pylint.extensions.set_membership",
    "pylint_quotes",
]

Command used

pylint a.py

Pylint output

************* Module a
a.py:11:8: R0204: Redefinition of potato type from a.Root to dict (redefined-variable-type)

------------------------------------------------------------------
Your code has been rated at 8.89/10 (previous run: 8.89/10, +0.00)

Expected behavior

Here's the output if the methods are not async:

class Root:
    ...


class TestTest:
    def test_one(self):
        potato = Root()
        assert potato

    def test_two(self):
        potato = {}
        assert potato
pylint a.py 

-------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 8.89/10, +1.11)

Pylint version

2.15.10

OS / Environment

Linux, Debian sid

Additional dependencies

No response

@benwah benwah added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Jan 27, 2023
@mbyrnepr2 mbyrnepr2 self-assigned this Jan 27, 2023
@mbyrnepr2 mbyrnepr2 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 Jan 27, 2023
@mbyrnepr2 mbyrnepr2 changed the title R0204: Redefinition of <name> type - False negative on async functions. R0204: Redefinition of <name> type - False positive on async functions. Jan 27, 2023
mbyrnepr2 added a commit to mbyrnepr2/pylint that referenced this issue Jan 27, 2023
mbyrnepr2 added a commit to mbyrnepr2/pylint that referenced this issue Jan 27, 2023
mbyrnepr2 added a commit that referenced this issue Jan 28, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
…ethods are present. (#8123)

Closes #8120
@mbyrnepr2
Copy link
Member

Thanks for raising this @benwah! Keep an eye out on the release date via the milestone

@benwah
Copy link
Author

benwah commented Jan 28, 2023

Wow fast resolution! Thanks!

@mbyrnepr2 mbyrnepr2 added this to the 2.16.0 milestone Jan 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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

Successfully merging a pull request may close this issue.

2 participants