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

Unpacking-non-sequence raises error for Callable in collections.abc #4895

Closed
TylerYep opened this issue Aug 22, 2021 · 2 comments · Fixed by pylint-dev/astroid#1143
Closed
Labels
Bug 🪲 False Positive 🦟 A message is emitted but nothing is wrong with the code Needs astroid update Needs an astroid update (probably a release too) before being mergable
Milestone

Comments

@TylerYep
Copy link

TylerYep commented Aug 22, 2021

Bug description

This instance of the bug is a regression in pylint 2.10.2. It does not appear in pylint 2.9.

from dataclasses import dataclass
from collections.abc import Callable


@dataclass
class Metric:
    function: Callable[..., tuple[int, int]]

    def update(self):
        _, _ = self.function()

Related issues:
#4137
#4696
#4803

Command used

pylint a.py

Pylint output

************* Module a
a.py:9:8: E0633: Attempting to unpack a non-sequence defined at line 502 of _collections_abc (unpacking-non-sequence)

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

Expected behavior

Shouldn't throw this error.

Pylint version

pylint 2.10.2
astroid 2.7.2
Python 3.9.2

OS / Environment

Mac OS

Additional dependencies

No response

@TylerYep TylerYep added Bug 🪲 Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Aug 22, 2021
@TylerYep TylerYep changed the title Unpacking-non-sequence Unpacking-non-sequence raises error for Callable in collections.abc Aug 22, 2021
@Pierre-Sassoulas
Copy link
Member

Thank for opening the issue, on ubuntu I'm getting:

************* Module a
a.py:7:14: E1136: Value 'Callable' is unsubscriptable (unsubscriptable-object)
a.py:7:28: E1136: Value 'tuple' is unsubscriptable (unsubscriptable-object)

------------------------------------
Your code has been rated at -6.67/10

If it's MacOs specific, we might need to do #4759 first.

@Pierre-Sassoulas Pierre-Sassoulas added False Positive 🦟 A message is emitted but nothing is wrong with the code and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Aug 22, 2021
@cdce8p
Copy link
Member

cdce8p commented Aug 22, 2021

@Pierre-Sassoulas Try it with at least Python 3.9 or add from __future__ import annotations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🪲 False Positive 🦟 A message is emitted but nothing is wrong with the code Needs astroid update Needs an astroid update (probably a release too) before being mergable
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants