Skip to content

(🐞) Crash with TypeGuard on __call__ #16187

Closed
@KotlinIsland

Description

@KotlinIsland
from typing import TypeGuard
class A:
    def __call__(self, a) -> TypeGuard[int]:
        return True

a: A
assert a(a=1)
> mypy test.py --tb
test.py:7: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 1.5.1
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "mypy\checker.py", line 584, in accept
    # least one type that we don't know.
  File "mypy\nodes.py", line 1435, in accept
  File "mypy\checker.py", line 4409, in visit_assert_stmt
    return  # The partial type is None.
  File "mypy\checker.py", line 5455, in find_isinstance_check
    return [typ], []
  File "mypy\checker.py", line 5501, in find_isinstance_check_helper
    """
AssertionError:
test.py:7: : note: use --pdb to drop into pdb

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions