Closed as not planned
Closed as not planned
Description
Bug Report
When using direct coroutine call in pattern matching construction, mypy complains about missing return statement.
But if the coroutine result previously has been assigned to a variable, and the variable was used in pattern matching then mypy is good with it
To Reproduce
async def func() -> bool | str:
return "a"
async def test_1() -> str:
match await func():
case str(s):
return s
case bool(bool_var):
match bool_var:
case True:
return "true"
case False:
return "false"
async def test_2() -> str:
r = await func()
match r:
case str(s):
return s
case bool(bool_var):
match bool_var:
case True:
return "true"
case False:
return "false"
Expected Behavior
No errors
Actual Behavior
example.py: note: In function "test_1":
example.py:5: error: Missing return statement [return]
async def test_1() -> str:
Found 1 error in 1 file (checked 1 source file)
Your Environment
- Mypy version used: 1.10.0
- Mypy command-line flags:
- Mypy configuration options from
mypy.ini
(and other config files):
pyproject.toml
[tool.mypy]
check_untyped_defs = true
enable_error_code = "explicit-override,unused-awaitable,ignore-without-code,truthy-bool,possibly-undefined,redundant-expr,redundant-self"
plugins = "sqlalchemy.ext.mypy.plugin"
pretty = true
show_error_context = true
strict = true
warn_unreachable = true
- Python version used: 3.12.2