You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[1.16 regression] Internal error: must never apply partial type #19213
main.py:19: 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.16.0
Traceback (most recent call last):
File "mypy/checkexpr.py", line 5926, in accept
File "mypy/nodes.py", line 2018, in accept
File "mypy/checkexpr.py", line 488, in visit_call_expr
File "mypy/checkexpr.py", line 622, in visit_call_expr_inner
File "mypy/checkexpr.py", line 1478, in check_call_expr_with_callee_type
File "mypy/checkexpr.py", line 1591, in check_call
File "mypy/checkexpr.py", line 2724, in check_overload_call
File "mypy/checkexpr.py", line 2885, in infer_overload_return_type
File "mypy/checkexpr.py", line 1580, in check_call
File "mypy/checkexpr.py", line 1752, in check_callable_call
File "mypy/checkexpr.py", line 2054, in infer_function_type_arguments_using_context
File "mypy/checkexpr.py", line 3260, in apply_generic_arguments
File "mypy/applytype.py", line 112, in apply_generic_arguments
AssertionError: Internal error: must never apply partial type
main.py:19: : note: use --pdb to drop into pdb
To Reproduce
main.py:
from typing import overload, TypeVar, Optional, Protocol
T = TypeVar('T')
class DbManager(Protocol):
@overload
def get(self, key: str) -> Optional[T]:
pass
@overload
def get(self, key: str, default: T) -> T:
pass
class Foo:
def __init__(self, db: DbManager, bar: bool):
if bar:
self.qux = db.get('qux')
else:
self.qux = {}
run mypy:
mypy --show-traceback main.py
Your Environment
Mypy version used: 1.16.0
Mypy command-line flags:
Mypy configuration options from mypy.ini (and other config files):
Python version used: 3.11.1
Operating system and version: Ubuntu 20.04.6 LTS
with mypy 1.15.0, I got error:
main.py:21: error: Need type annotation for "qux" (hint: "qux: dict[<type>, <type>] = ...") [var-annotated]
Found 1 error in 1 file (checked 1 source file)
But with mypy 1.16.0, I got error:
main.py:19: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
If this issue continues with mypy master, please report a bug at https://github.com/python/mypy/issues
version: 1.16.0
main.py:19: : note: please use --show-traceback to print a traceback when reporting a bug
changed the title [-]Internal error: must never apply partial type[/-][+][1.16 regression] Internal error: must never apply partial type[/+]on Jun 3, 2025
@sterliakov Essentially the crash happens in the case where the outer (return) type context is used. I used the original example in the test before seeing your comment, but I think it is OK.
Activity
[-]Internal error: must never apply partial type[/-][+][1.16 regression] Internal error: must never apply partial type[/+]hauntsaninja commentedon Jun 3, 2025
Thanks for the report, bisects to #18847
sterliakov commentedon Jun 3, 2025
The snippet has obvious typing error, but hard crash is certainly too much... MRE without overload:
Note that
Tinstead ofT | Noneprevents crash.ilevkivskyi commentedon Jun 3, 2025
@sterliakov Essentially the crash happens in the case where the outer (return) type context is used. I used the original example in the test before seeing your comment, but I think it is OK.
Fix crash on partial type used as context (#19216)
Fix crash on partial type used as context (#19216)