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

Mypy reports a missing return statement despite all cases of match statement return something #12071

Closed
adonig opened this issue Jan 25, 2022 · 1 comment
Labels
bug mypy got something wrong topic-match-statement Python 3.10's match statement

Comments

@adonig
Copy link

adonig commented Jan 25, 2022

Bug Report

mypy reports a missing return statement despite all cases of a Python 3.10 match statement return something.

To Reproduce

Try this piece of code:

    def token_is_start_of_value(self) -> bool:
        """Check whether the current token is the start of a value.

        Returns:
            bool: True if the current token is the start of a value.
        """
        match self.token_type:
            case TokenType.DELIMITER if self.token in ("[", "{"):
                return True
            case TokenType.STRING | TokenType.NUMBER | TokenType.SYMBOL:
                return True
            case _:
                return False

Expected Behavior

mypy should not report a missing return statement.

Actual Behavior

mypy reports a missing return statement, see here:

Screen Shot 2022-01-25 at 21 29 01

Your Environment

  • Mypy version used: current master (0.940+dev.99f4d5af147d364eda1d4b99e79770c171896f13 99f4d5a)
  • Mypy command-line flags:
  • Mypy configuration options from mypy.ini (and other config files):
  • Python version used: Python 3.10.1
  • Operating system and version: macOS Monterey 12.0.1 (21A559)
@adonig adonig added the bug mypy got something wrong label Jan 25, 2022
@JelleZijlstra JelleZijlstra added the topic-match-statement Python 3.10's match statement label Jan 25, 2022
@JelleZijlstra
Copy link
Member

Duplicate of #12010

@JelleZijlstra JelleZijlstra marked this as a duplicate of #12010 Jan 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-match-statement Python 3.10's match statement
Projects
None yet
Development

No branches or pull requests

2 participants