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

Error analyzing spacy #10542

Closed
ZeeD opened this issue May 27, 2021 · 4 comments
Closed

Error analyzing spacy #10542

ZeeD opened this issue May 27, 2021 · 4 comments
Labels
bug mypy got something wrong

Comments

@ZeeD
Copy link

ZeeD commented May 27, 2021

Bug Report

mypy hangs and (after a long time) report an error trying to analyze code using spacy

To Reproduce

I'm using latest versions of spacy and mypy. Analyzing in strict mode raise an AssertionError inside mypy

> type foo.py
from spacy import load
> type mypy.ini
[mypy]
strict = True
> mypy foo.py
Traceback (most recent call last):
  File "c:\Program Files\Python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\Program Files\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\vito.detullio\Desktop\DELME\venv\Scripts\mypy.exe\__main__.py", line 7, in <module>
  File "c:\users\vito.detullio\desktop\delme\venv\lib\site-packages\mypy\__main__.py", line 11, in console_entry
    main(None, sys.stdout, sys.stderr)
  File "mypy\main.py", line 90, in main
  File "mypy\build.py", line 179, in build
  File "mypy\build.py", line 253, in _build
  File "mypy\build.py", line 2638, in dispatch
  File "mypy\build.py", line 2962, in process_graph
  File "mypy\build.py", line 3079, in process_stale_scc
  File "mypy\build.py", line 2251, in write_cache
  File "mypy\build.py", line 1461, in write_cache
  File "mypy\nodes.py", line 313, in serialize
  File "mypy\nodes.py", line 3140, in serialize
  File "mypy\nodes.py", line 3076, in serialize
AssertionError

I'm on windows 10 (20H2), using python and this is my setup:

> python --version
Python 3.9.1
> python -mpip freeze
blis==0.7.4
catalogue==2.0.4
certifi==2020.12.5
chardet==4.0.0
click==7.1.2
cymem==2.0.5
en-core-web-sm @ https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.0.0/en_core_web_sm-3.0.0-py3-none-any.whl
idna==2.10
Jinja2==3.0.1
MarkupSafe==2.0.1
murmurhash==1.0.5
mypy==0.812
mypy-extensions==0.4.3
numpy==1.20.3
packaging==20.9
pathy==0.5.2
preshed==3.0.5
pydantic==1.7.4
pyparsing==2.4.7
requests==2.25.1
smart-open==3.0.0
spacy==3.0.6
spacy-legacy==3.0.5
srsly==2.4.1
thinc==8.0.3
tqdm==4.61.0
typed-ast==1.4.3
typer==0.3.2
typing-extensions==3.10.0.0
urllib3==1.26.5
wasabi==0.8.2

mypy foo.py should return "Success: no issues found in 1 source file" as espected from the content of the file

@ZeeD ZeeD added the bug mypy got something wrong label May 27, 2021
@TheCleric
Copy link
Contributor

@ZeeD Running this myself, (with some tweaked logging in my local mypy), the issue was because mypy was having issues resolving spacy.ml.models.multi_task.Doc. Looking into it in your code base, I do see some imports in multi_task.py around Doc to avoid circular references.

I was able to resolve it within your code by changing to the two imports of Doc from from ...tokens import Doc to from ...tokens.doc import Doc.

As well I'll submit a PR to mypy to help these become easier to find later.

TheCleric added a commit to TheCleric/mypy that referenced this issue May 31, 2021
hauntsaninja added a commit that referenced this issue May 31, 2021
Helps with #10542

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Co-authored-by: hauntsaninja <>
@ZeeD
Copy link
Author

ZeeD commented Jun 1, 2021

just a note: the only code that is "mine" is the from spacy import load line of foo.py. I'm not a spacy developer, just a user :)
I have opened an issue to them with your suggestion

@TheCleric
Copy link
Contributor

TheCleric commented Jun 1, 2021

just a note: the only code that is "mine" is the from spacy import load line of foo.py. I'm not a spacy developer, just a user :)

I have opened an issue to them with your suggestion

Ahh. Sorry for assuming. 😂

Not sure if they would be open to PRs but this would be an easy contribution (and more likely to actually get fixed) if you wanted to submit a PR to them.

@ZeeD
Copy link
Author

ZeeD commented Jun 2, 2021

I followed your suggestion an made the PR (that was merged! yay!)
I think this specifig bug can be closed

@ZeeD ZeeD closed this as completed Jun 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

2 participants