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

Obvious errors with coroutines are not detected #10841

Closed
WhyNotHugo opened this issue Jul 20, 2021 · 4 comments
Closed

Obvious errors with coroutines are not detected #10841

WhyNotHugo opened this issue Jul 20, 2021 · 4 comments
Labels
bug mypy got something wrong

Comments

@WhyNotHugo
Copy link

Bug Report

Some obvious type issues with coroutines are not detected. See two examples below.

To Reproduce

import asyncio


async def function_one():
    return 1


async def function_two():
    function_one()[1]
    function_one() + 1


asyncio.run(function_two())

Expected Behavior

mypy should detect two TypeError here:

  • 'coroutine' object is not subscriptable
  • unsupported operand type(s) for +: 'coroutine' and 'int'

Actual Behavior

Success: no issues found in 1 source file

Your Environment

mypy 0.910
Python 3.9.6

@WhyNotHugo WhyNotHugo added the bug mypy got something wrong label Jul 20, 2021
@WhyNotHugo
Copy link
Author

Odd, a couroutine is never indexable, shouldn't mypy be able to detect this even if it's not type-annotated?

@JelleZijlstra
Copy link
Member

It can, yes, but mypy simply never provides errors for functions that aren't type checked.

@JelleZijlstra
Copy link
Member

You can use the --check-untyped-defs option to change this behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

3 participants