Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

False unreachable warning on match statement #14485

Copy link
Copy link
Open
@delfick

Description

@delfick
Issue body actions

Bug Report

Hello,

I want to do something like:

def match(info: RequestContext):
    match info:
        case RequestContext.ForPopup(data_only_in_popup_context=data):
            print(data)
        case RequestContext.ForDetailPage(data_only_in_detail_page=data):
            print(data)

However I'm getting unreachable warnings when --warn-unreachable is turned on. But the code I have does indeed reach that line.

To Reproduce

https://gist.github.com/delfick/e7974027a422f8f212887e490e5d3a75

Expected Behavior

I expect no errors when running with mypy and the warn-unreachable option.

Actual Behavior

When I run python example.py I get expected output

For popup <__main__.Request object at 0x10326a620> (1,) {'1': '2'}
For details page <__main__.Request object at 0x10326a0b0> {'3': '4'}
For popup {'1': '2'}
For details page {'3': '4'}

When I run mypy example.py --warn-unreachable I get

example.py:49: error: Statement is unreachable  [unreachable]
example.py:65: error: Statement is unreachable  [unreachable]
Found 2 errors in 1 file (checked 1 source file)

Your Environment

  • Mypy version used: 0.991
  • Mypy command-line flags: --warn-unreachable
  • Mypy configuration options from mypy.ini (and other config files): N/A
  • Python version used: 3.10.8

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.