[mypy] Module "spacy" does not explicitly export attribute "prefer_gpu" when using --no-implicit-reexport
- Dominant language
- Python
- Stars
- 33.9k
- Forks
- 4.7k
- Avg merge
- 3m
- Merged PRs (30d)
- 1
Description
First of all, thank you for maintaining a well type annotated library. It's a joy to use!
This bug is a minor issue when using spacy with `mypy --no-implicit-reexport`. I do not know if you care about `--no-implicit-reexport`, so feel free to ignore if you don't.
**Brief explanation of the switch (in case):** mypy's --no-implicit-reexport allows modules to be more specific about what in its namespace is part of the public API. Using it, by default, a module doing `from foo import X` does not, for type checking purposes, export the symbol `X` to importing modules, i.e. the import is assumed to be private by default. I believe the canonical way to explicitly reexport an imported symbol is the slightly funny looking `from thinc.api import prefer_gpu as prefer_gpu`.
## How to reproduce the behaviour
1. Install mypy 1.8.0
2. Create a file `bug.py` with the contents
```python
import spacy
spacy.prefer_gpu()
```
3. run `mypy --strict --no-implicit-reexport bug.py`
**Expected outcome:**
There are no errors from mypy.
**Actual outcome:**
mypy reports
`bug.py:3: error: Module "spacy" does not explicitly export attribute "prefer_gpu" [attr-defined]`
## Info about spaCy
- **spaCy version:** 3.7.2
- **Platform:** Linux-6.2.0-1018-lowlatency-x86_64-with-glibc2.37
- **Python version:** 3.11.4
- **mypy version:** 1.8.0
Contributor guide
Assessment
This issue has not been assessed yet.