-
Notifications
You must be signed in to change notification settings - Fork 17
Mypy plugin crashes on an assertion error #559
Copy link
Copy link
Closed
Labels
bugError, flaw, or fault that causes unexpected behaviorError, flaw, or fault that causes unexpected behavior
Milestone
Description
Describe the problem.
When upgrading the extensions package to proxystore==0.6.5, I got the following mypy crash.
proxystore-extensions$ mypy proxystore_ex/plugins/distributed.py --show
-traceback
proxystore_ex/plugins/distributed.py:406: 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.10.0
Traceback (most recent call last):
File "mypy/checkexpr.py", line 5760, in accept
File "mypy/nodes.py", line 1831, in accept
File "mypy/checkexpr.py", line 3243, in visit_member_expr
File "mypy/checkexpr.py", line 3264, in analyze_ordinary_member_access
File "mypy/checkmember.py", line 205, in analyze_member_access
File "mypy/checkmember.py", line 229, in _analyze_member_access
File "mypy/checkmember.py", line 466, in analyze_union_member_access
File "mypy/checkmember.py", line 224, in _analyze_member_access
File "mypy/checkmember.py", line 352, in analyze_instance_member_access
File "mypy/checkmember.py", line 573, in analyze_member_var_access
File "/home/jgpaul/workspace/proxystore-extensions/venv/lib/python3.11/site-packages/proxystore/mypy_plugin.py", line 90, in proxy_attribute_access
assert isinstance(ctx.type, Instance)
AssertionError:
proxystore_ex/plugins/distributed.py:406: : note: use --pdb to drop into pdb
The crash happens on this line: https://github.com/proxystore/extensions/blob/b0aba0fc840316e8f1a716343194d7d4d3ad2359/proxystore_ex/plugins/distributed.py#L406
In v0.6.5, __factory__ no longer exists so I'd expect a mypy error but not a crash. Fixing those lines to use get_factory() fixes the crash, but I'd like to avoid crashing entirely.
Here's a minimal reproducer:
from typing import Callable, TypeVar
from proxystore.proxy import Proxy
T = TypeVar('T')
def foo(x: T | Proxy[T]) -> T | Callable[[], T]:
if isinstance(x, Proxy):
return x.__factory__ # crashes
else:
return x
x = Proxy(lambda: 42)
x.__factory__ # errors correctly that int has no attribute __factory__The error seems specific to foo()'s parameter x being T | Proxy[T]. Removing the union and just having x: Proxy[T] makes the crash go away.
How did you install ProxyStore?
$ pip install proxystoreProxyStore Version
v0.6.5
Python Version
All
OS and Platform
All
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugError, flaw, or fault that causes unexpected behaviorError, flaw, or fault that causes unexpected behavior