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

Irrefutable pattern doesn't count properly for a calculation of a function return type #7730

Closed
enaydanov opened this issue Nov 8, 2022 · 1 comment
Labels
Control flow Requires control flow understanding Duplicate 🐫 Duplicate of an already existing issue False Positive 🦟 A message is emitted but nothing is wrong with the code Match case python 3.10

Comments

@enaydanov
Copy link

Bug description

# pylint: disable=missing-docstring

def repro(selector: str) -> dict:
    match selector:
        case "a":
            return {"selected": "a"}
        case _:  # can be a simple capture pattern too
            raise ValueError(f"Unknown value: {selector}")


print(repro("a")["selector"])

Configuration

No response

Command used

pylint repro.py

Pylint output

************* Module repro
repro.py:9:6: E1136: Value 'repro('a')' is unsubscriptable (unsubscriptable-object)

Expected behavior


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

Pylint version

pylint 2.15.5
astroid 2.12.12
Python 3.11.0 (main, Nov  2 2022, 05:40:18) [GCC 7.5.0]

OS / Environment

No response

Additional dependencies

No response

@enaydanov enaydanov added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Nov 8, 2022
@Pierre-Sassoulas Pierre-Sassoulas added Control flow Requires control flow understanding False Positive 🦟 A message is emitted but nothing is wrong with the code Needs investigation 🔬 A bug or crash where it's not immediately obvious what is happenning and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Nov 8, 2022
@jacobtylerwalls jacobtylerwalls added Duplicate 🐫 Duplicate of an already existing issue and removed Needs investigation 🔬 A bug or crash where it's not immediately obvious what is happenning labels Feb 26, 2023
@jacobtylerwalls
Copy link
Member

Duplicate of #5288

@jacobtylerwalls jacobtylerwalls marked this as a duplicate of #5288 Feb 26, 2023
@jacobtylerwalls jacobtylerwalls closed this as not planned Won't fix, can't repro, duplicate, stale Feb 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Control flow Requires control flow understanding Duplicate 🐫 Duplicate of an already existing issue False Positive 🦟 A message is emitted but nothing is wrong with the code Match case python 3.10
Projects
None yet
Development

No branches or pull requests

4 participants