Closed ZeeD closed 2 years ago
Hm, that's ... interesting. It feels like this might be a bug on our end, so I labeled it as such for now. I'm a bit unsure how this can pop up though. Just to confirm: you're not getting any errors when running mypy
on just the spacy
repo, right?
you mean on a clone of this repository? I'll try later
Yes exactly. We run mypy
as part of the CI, and we don't get these kind of failures, so I'm trying to understand what's going on. I see two options: either something in your configuration / mypy
version is resulting in the error, or the error happens only when spacy
is used as a dependency in another project. Which is why it would be helpful if you'd try running mypy
on the spacy
repo by itself, so we can get to the bottom of this!
same machine, python/mypy interpreter, virtualenv, etc. No errors with mypy
. Some errors with mypy strict
but no "hard crash" with the AssertionError
>git clone https://github.com/explosion/spaCy.git
Cloning into 'spaCy'...
remote: Enumerating objects: 99714, done.
remote: Counting objects: 100% (2746/2746), done.
remote: Compressing objects: 100% (1468/1468), done.
remote: Total 99714 (delta 1825), reused 1910 (delta 1276), pack-reused 96968
Receiving objects: 100% (99714/99714), 181.15 MiB | 3.89 MiB/s, done.
Resolving deltas: 100% (74711/74711), done.
Updating files: 100% (1556/1556), done.
>cd spaCy
>mypy spacy
spacy\tests\pipeline\test_analysis.py:3: error: Library stubs not installed for "mock" (or incompatible with Python 3.8)
spacy\tests\matcher\test_phrase_matcher.py:3: error: Library stubs not installed for "mock" (or incompatible with Python 3.8)
spacy\tests\doc\test_underscore.py:2: error: Library stubs not installed for "mock" (or incompatible with Python 3.8)
spacy\tests\doc\test_underscore.py:2: note: Hint: "python3 -m pip install types-mock"
spacy\tests\doc\test_underscore.py:2: note: (or run "mypy --install-types" to install all missing stub packages)
spacy\tests\doc\test_underscore.py:2: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
spacy\tests\matcher\test_matcher_api.py:2: error: Library stubs not installed for "mock" (or incompatible with Python 3.8)
spacy\tests\matcher\test_dependency_matcher.py:5: error: Library stubs not installed for "mock" (or incompatible with Python 3.8)
Found 5 errors in 5 files (checked 740 source files)
>mypy --install-types
[...]
>mypy spacy
Success: no issues found in 740 source files
>mypy --strict spacy
[...]
Found 4550 errors in 451 files (checked 740 source files)
>
+1, having this same problem.
currently just ignoring the entire file in which spacy
is imported during type checks. I was able to allow it to pass by telling mypy to skip following imports on that file, but it still added so much time to type-checking that skipping the file entirely was preferable.
+1 I'm getting this too
+1, also getting this issue. Any update? :)
I can't reproduce this with this config:
mypy==0.942
mypy-extensions==0.4.3
spacy==3.2.3
Python version 3.10.2, Linux.
I ran mypy --strict check.py
where check.py
is just import spacy
, like the initial post.
If you are encountering this error, please share the versions of the related software you're using.
It's not really clear to us why this would be happening - as mentioned upthread, we run mypy on spaCy itself as part of our CI.
Some things that might be at issue:
did some investigating against spacy==3.1.0
and spacy==3.2.0
and found the issue was with the mypy==0.910
version in the original issue.
docker run --rm -ti python:3.8.0 bash
pip3 install spacy==3.2.0 mypy==0.910 mypy-extensions==0.4.3
echo "import spacy" > check.py
mypy --strict check.py
fix was in the following version:
pip install mypy==0.920
mypy --strict check.py
Excellent, thank you for tracking that down! I was indeed able to reproduce the error by downgrading to 0.910.
I'll mark this as resolved, but if anyone is still having issues please let us know.
This issue has been automatically closed because it was answered and there was no follow-up discussion.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
I see errors while using mypy on any codebase that relies on spacy.
How to reproduce the behaviour
issue.py
mypy.ini
trying to run mypy gives me this:
I'm on windows, with python 3.8.0 and the latest versions of spacy and mypy