Open aberres opened 3 years ago
No idea if this is intended or not, but when I compare the dmypy and the mypy output I notice something else:
dmypy checks way more files, while mypy only cares about the passed package. When I do not pass pretty=True
instead of a crash I get the bogus error messages for numpy as errors:
First run
> dmypy run -- --config-file mypy.ini -p flask_rest_json_api
backend/flask-rest-json-api/flask_rest_json_api/resource.py:146: error: Need type annotation for "schema_kwargs" [var-annotated]
backend/flask-rest-json-api/flask_rest_json_api/resource.py:272: error: Need type annotation for "schema_kwargs" [var-annotated]
Found 2 errors in 1 file (checked 405 source files)
Second run
> dmypy run -- --config-file mypy.ini -p flask_rest_json_api
/Users/berres/venv/xyx/lib/python3.9/site-packages/numpy/core/overrides.py:2936: error: Class numpy.number has abstract attributes "__init__" [misc]
/Users/berres/venv/xyx/lib/python3.9/site-packages/numpy/core/overrides.py:2936: note: If it is meant to be abstract, add 'abc.ABCMeta' as an explicit metaclass
/Users/berres/venv/xyx/lib/python3.9/site-packages/numpy/core/overrides.py:3088: error: Class numpy.integer has abstract attributes "__init__" [misc]
/Users/berres/venv/xyx/lib/python3.9/site-packages/numpy/core/overrides.py:3088: note: If it is meant to be abstract, add 'abc.ABCMeta' as an explicit metaclass
/Users/berres/venv/xyx/lib/python3.9/site-packages/numpy/core/overrides.py:3244: error: Class numpy.inexact has abstract attributes "__init__" [misc]
/Users/berres/venv/xyx/lib/python3.9/site-packages/numpy/core/overrides.py:3244: note: If it is meant to be abstract, add 'abc.ABCMeta' as an explicit metaclass
/Users/berres/venv/xyx/lib/python3.9/site-packages/numpy/core/overrides.py:3344: error: Class numpy.flexible has abstract attributes "__init__" [misc]
/Users/berres/venv/xyx/lib/python3.9/site-packages/numpy/core/overrides.py:3344: note: If it is meant to be abstract, add 'abc.ABCMeta' as an explicit metaclass
/Users/berres/venv/xyx/lib/python3.9/site-packages/numpy/core/overrides.py:3363: error: Class numpy.character has abstract attributes "__init__" [misc]
/Users/berres/venv/xyx/lib/python3.9/site-packages/numpy/core/overrides.py:3363: note: If it is meant to be abstract, add 'abc.ABCMeta' as an explicit metaclass
backend/flask-rest-json-api/flask_rest_json_api/resource.py:146: error: Need type annotation for "schema_kwargs" [var-annotated]
backend/flask-rest-json-api/flask_rest_json_api/resource.py:272: error: Need type annotation for "schema_kwargs" [var-annotated
Pure mypy
> mypy -p flask_rest_json_api --config mypy.ini
backend/flask-rest-json-api/flask_rest_json_api/resource.py:146: error: Need type annotation for "schema_kwargs" [var-annotated]
backend/flask-rest-json-api/flask_rest_json_api/resource.py:272: error: Need type annotation for "schema_kwargs" [var-annotated]
Found 2 errors in 1 file (checked 24 source files)
I am trying to come up with a minimal reproduction, but it is not really obvious for me, why the numpy error is raised here.
What I know is that I have a dependency chain flask_rest_json_api->OtherPackage->numpy (not nice, but...).
When trying to reproduce I noticed something else which might be related: dmypy has sometimes problems to only check for errors in the specified package.
Repro:
1) Install a package which has no mypy errors
2) Start dmypy server like dmypy daemon -- -p my_package --verbose
3) Trigger check dmypy run -- -p my_package --verbose
- everything is fine
4) Add an import which has mypy errors when checked individually. E.g. import marshmallow
.
5) Rerun dmypy run -- -p my_package --verbose
and observe a bunch of errors directly in marshmallow.
6) Restart dmypy and observe that errors are gone.
Does this reproduce on master? It sounds like the kind of issue that #10937 recently fixed.
@JelleZijlstra Yeps, could reproduce with master. Only dmymy has the problem, could not crash things with mypy only.
I'm getting the same issues the second time I run dmypy run .
, after just updating to numpy
1.21.2 (I get the same extra errors reported for numpy
, and I get that crash if I add pretty = True
to my config). Using Python 3.8 and mypy 0.790.
I'm getting the same issues the second time I run
dmypy run .
, after just updating tonumpy
1.21.2 (I get the same extra errors reported fornumpy
, and I get that crash if I addpretty = True
to my config). Using Python 3.8 and mypy 0.790.
I no longer see this issue on numpy
1.22.3 and Python 3.9.7, so possibly one of these updates fixed the issue. Still using the same version of mypy
.
Although if a change in numpy
can cause the daemon to crash like this it's possible there's still an underlying issue that needs to be fixed, but this no longer seems as important if it has cleared up
Crash Report
When dmypy is run the second time it crashes when trying to update its internal state. No code has been changed between runs.
Traceback
To Reproduce
I do not yet have a stand alone repo, but collected some logs what happens.
The problematic call is simply
dmypy run -- --config-file mypy.ini -p flask_rest_json_api
In the config we set
pretty=True
which causes the error to show up.When the crash happens, dmypy tries to update the error messages for the system wide installed
numpy
. The detected error is absolutely bogus. Thefile python3.9/site-packages/numpy/core/overrides.py
has only 227 lines while multiple errors are detected between lines 2936 and 3363 (see log below). Hence the crash.The thing is: We are not at all interested in these numpy errors. Numpy should not be a package errors are reported for. And the first run actually does not report any numpy errors.
The verbose logs from the second run. As we see
numpy.compat
is considered to be deleted. Theintegrity_problem
log has beed added by myself.Your Environment
mypy.ini
(and other config files):