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 when using imported class with partial #14687

Closed
NeilGirdhar opened this issue Feb 13, 2023 · 2 comments · Fixed by #14885
Closed

Crash when using imported class with partial #14687

NeilGirdhar opened this issue Feb 13, 2023 · 2 comments · Fixed by #14885

Comments

@NeilGirdhar
Copy link
Contributor

NeilGirdhar commented Feb 13, 2023

This relies on tjax version 0.26 (tagged and released to PyPI).

from functools import partial

from tjax import custom_jvp  # Copying the definition into the file does not crash.


@partial(custom_jvp)
def f(x: int) -> None:
    pass

Produces:

a.py:6: 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.0.0
Traceback (most recent call last):
  File "mypy/checkexpr.py", line 4821, in accept
  File "mypy/nodes.py", line 1891, in accept
  File "mypy/checkexpr.py", line 425, in visit_call_expr
  File "mypy/checkexpr.py", line 545, in visit_call_expr_inner
  File "mypy/checkexpr.py", line 1197, in check_call_expr_with_callee_type
  File "mypy/checkexpr.py", line 1280, in check_call
  File "mypy/checkexpr.py", line 1471, in check_callable_call
  File "mypy/checkexpr.py", line 2122, in check_argument_types
  File "mypy/checkexpr.py", line 2166, in check_arg
  File "mypy/subtypes.py", line 176, in is_subtype
  File "mypy/subtypes.py", line 335, in _is_subtype
  File "mypy/types.py", line 1860, in accept
  File "mypy/subtypes.py", line 686, in visit_callable_type
  File "mypy/subtypes.py", line 1423, in is_callable_compatible
  File "mypy/subtypes.py", line 1717, in unify_generic_callable
  File "mypy/solve.py", line 88, in solve_constraints
  File "mypy/subtypes.py", line 176, in is_subtype
  File "mypy/subtypes.py", line 335, in _is_subtype
  File "mypy/types.py", line 705, in accept
  File "mypy/subtypes.py", line 649, in visit_param_spec
  File "mypy/subtypes.py", line 388, in _is_subtype
  File "mypy/subtypes.py", line 176, in is_subtype
  File "mypy/subtypes.py", line 335, in _is_subtype
  File "mypy/types.py", line 1348, in accept
  File "mypy/subtypes.py", line 435, in visit_instance
AttributeError: attribute 'fallback_to_any' of 'TypeInfo' undefined
a.py:6: : note: use --pdb to drop into pdb
@NeilGirdhar NeilGirdhar added the bug mypy got something wrong label Feb 13, 2023
@hauntsaninja hauntsaninja added crash and removed bug mypy got something wrong labels Feb 13, 2023
@hauntsaninja
Copy link
Collaborator

Hm, I cannot repro this with mypy 1.0.0 and tjax 0.26. If you have a consistent repro in a clean environment, maybe share pip freeze?

@NeilGirdhar
Copy link
Contributor Author

@hauntsaninja Apparently when I run it twice, then it crashes:

❯ mypy a.py
a.py:6: error: Argument 1 to "partial" has incompatible type "Type[custom_jvp[Any, Any, Any]]"; expected "Callable[..., custom_jvp[U, P, R_co]]"  [arg-type]
Found 1 error in 1 file (checked 1 source file)
❯ mypy a.py
a.py:6: 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.0.0
a.py:6: : note: please use --show-traceback to print a traceback when reporting a bug
❯ mypy a.py
a.py:6: 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.0.0
a.py:6: : note: please use --show-traceback to print a traceback when reporting a bug

So it may be cache related. Here's my pip freeze:

absl-py==1.4.0
anyio==3.6.2
appnope==0.1.3
argon2-cffi==21.3.0
argon2-cffi-bindings==21.2.0
arrow==1.2.3
astroid==2.14.1
asttokens==2.2.1
astunparse==1.6.3
attrs==22.2.0
backcall==0.2.0
beautifulsoup4==4.11.2
bleach==6.0.0
cachetools==5.3.0
certifi==2022.12.7
cffi==1.15.1
charset-normalizer==3.0.1
chex==0.1.6
click==8.1.3
cloudpickle==2.2.1
-e git+ssh://[email protected]/NeilGirdhar/cmm.git@4576d13a457df72c540a3096a004bca2a352acb6#egg=cmm
comm==0.1.2
contourpy==1.0.7
cycler==0.11.0
debugpy==1.6.6
decorator==5.1.1
defusedxml==0.7.1
dill==0.3.6
dm-haiku==0.0.9
dm-tree==0.1.8
efax==1.11.0
entrypoints==0.4
etils==1.0.0
exceptiongroup==1.1.0
executing==1.2.0
fastjsonschema==2.16.2
flake8==6.0.0
flatbuffers==23.1.21
fonttools==4.38.0
fqdn==1.5.1
gast==0.4.0
google-auth==2.16.0
google-auth-oauthlib==0.4.6
google-pasta==0.2.0
googleapis-common-protos==1.58.0
grpcio==1.51.1
h5py==3.8.0
idna==3.4
importlib-resources==5.10.2
iniconfig==2.0.0
ipykernel==6.21.1
ipython==8.9.0
ipython-genutils==0.2.0
ipywidgets==8.0.4
isoduration==20.11.0
isort==5.12.0
jax==0.4.2
jaxlib==0.4.2
jedi==0.18.2
Jinja2==3.1.2
jmp==0.0.4
jsonpointer==2.3
jsonschema==4.17.3
jupyter==1.0.0
jupyter-console==6.4.4
jupyter-events==0.6.3
jupyter_client==8.0.2
jupyter_core==5.2.0
jupyter_server==2.2.1
jupyter_server_terminals==0.4.4
jupyterlab-pygments==0.2.2
jupyterlab-widgets==3.0.5
keras==2.11.0
kiwisolver==1.4.4
lazy-object-proxy==1.9.0
libclang==15.0.6.1
Markdown==3.4.1
markdown-it-py==2.1.0
MarkupSafe==2.1.2
matplotlib==3.6.3
matplotlib-inline==0.1.6
mccabe==0.7.0
mdurl==0.1.2
mistune==2.0.4
more-itertools==9.0.0
mypy==1.0.0
mypy-extensions==1.0.0
nbclassic==0.5.1
nbclient==0.7.2
nbconvert==7.2.9
nbformat==5.7.3
nest-asyncio==1.5.6
networkx==3.0
nodeenv==1.7.0
notebook==6.5.2
notebook_shim==0.2.2
numpy==1.24.2
oauthlib==3.2.2
opt-einsum==3.3.0
optax==0.1.4
packaging==23.0
pandas==1.5.3
pandocfilters==1.5.0
parso==0.8.3
pexpect==4.8.0
pickleshare==0.7.5
Pillow==9.4.0
platformdirs==3.0.0
pluggy==1.0.0
progressbar2==4.2.0
prometheus-client==0.16.0
promise==2.3
prompt-toolkit==3.0.36
protobuf==3.19.6
psutil==5.9.4
ptyprocess==0.7.0
pure-eval==0.2.2
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycodestyle==2.10.0
pycparser==2.21
pyflakes==3.0.1
Pygments==2.14.0
pylint==2.16.1
pylint-pytest==1.1.2
pyparsing==3.0.9
pyproject-flake8==6.0.0.post1
pyright==1.1.292
pyrsistent==0.19.3
pytest==7.2.1
python-dateutil==2.8.2
python-json-logger==2.0.4
python-utils==3.4.5
pytz==2022.7.1
PyYAML==6.0
pyzmq==25.0.0
qtconsole==5.4.0
QtPy==2.3.0
requests==2.28.2
requests-oauthlib==1.3.1
rfc3339-validator==0.1.4
rfc3986-validator==0.1.1
rich==13.3.1
rsa==4.9
scipy==1.10.0
seaborn==0.12.2
Send2Trash==1.8.0
six==1.16.0
sniffio==1.3.0
soupsieve==2.3.2.post1
stack-data==0.6.2
structlog==22.3.0
tabulate==0.9.0
tensorboard==2.11.2
tensorboard-data-server==0.6.1
tensorboard-plugin-wit==1.8.1
tensorflow==2.11.0
tensorflow-datasets==4.8.2
tensorflow-estimator==2.11.0
tensorflow-io-gcs-filesystem==0.30.0
tensorflow-metadata==1.12.0
tensorflow-probability==0.19.0
termcolor==2.2.0
terminado==0.17.1
tinycss2==1.2.1
tjax==0.26.0
toml==0.10.2
tomli==2.0.1
tomlkit==0.11.6
toolz==0.12.0
tornado==6.2
tqdm==4.64.1
traitlets==5.9.0
typer==0.7.0
typing_extensions==4.4.0
uri-template==1.2.0
urllib3==1.26.14
wcwidth==0.2.6
webcolors==1.12
webencodings==0.5.1
websocket-client==1.5.1
Werkzeug==2.2.2
widgetsnbextension==4.0.5
wrapt==1.14.1
zipp==3.12.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants