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

(🐞) Crash with TypeGuard on __call__ #16187

Closed
KotlinIsland opened this issue Sep 27, 2023 · 0 comments · Fixed by #16516
Closed

(🐞) Crash with TypeGuard on __call__ #16187

KotlinIsland opened this issue Sep 27, 2023 · 0 comments · Fixed by #16516
Labels
crash topic-typeguard TypeGuard / PEP 647

Comments

@KotlinIsland
Copy link
Contributor

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
@AlexWaygood AlexWaygood added the topic-typeguard TypeGuard / PEP 647 label Sep 27, 2023
JukkaL pushed a commit that referenced this issue Nov 22, 2023
Fixes #16187

Note there may be some more similar crashes, I don't handle them all
properly, for now I leave a TODO and replace the `assert` with `if`, so
at least we should not crash on an unhandled case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash topic-typeguard TypeGuard / PEP 647
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants