Default mypy configuration crashes on python build without sqlite
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Crash Report
Since PR #21041 the sqlite cache is used by default.
This however fails when python was build without sqlite3 support and causes mypy to report an INTERNAL ERROR..
Traceback
- v1.20.1
Traceback (most recent call last):
File ".../site-packages/mypy/__main__.py", line 15, in console_entry
main()
File "mypy/main.py", line 141, in main
File "mypy/main.py", line 231, in run_build
File "mypy/build.py", line 388, in build
File "mypy/build.py", line 462, in build_inner
File "mypy/build.py", line 877, in __init__
File "mypy/build.py", line 1619, in create_metastore
File "mypy/metastore.py", line 181, in __init__
File "mypy/metastore.py", line 158, in connect_db
File ".../sqlite3/__init__.py", line 57, in <module>
from sqlite3.dbapi2 import *
File ".../sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ModuleNotFoundError: No module named '_sqlite3'
- v2.0.0:
Traceback (most recent call last):
File ".../site-packages/mypy/__main__.py", line 16, in console_entry
main()
File "mypy/main.py", line 154, in main
File "mypy/main.py", line 244, in run_build
File "mypy/build.py", line 385, in build
File "mypy/build.py", line 1911, in create_metastore
File "mypy/metastore.py", line 200, in __init__
File "mypy/metastore.py", line 166, in connect_db
File ".../sqlite3/__init__.py", line 57, in <module>
from sqlite3.dbapi2 import *
File ".../sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ModuleNotFoundError: No module named '_sqlite3'
To Reproduce
Build a python when the sqlite libraries are not installed.
Your Environment
- Mypy version used: 1.20.2 (and also tested on 2.0.0)
- Python versions: 3.10, 3.11 (later untested)
Work-arounds
- Run with:
mypy --no-sqlite-cache - Update pyproject.toml:
[tool.mypy]
sqlite_cache = false
- Update mypy.ini:
[mypy]
sqlite_cache=false
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with mypy/metastore.py, especially connect_db, and trace how mypy/build.py creates the metastore. Reproduce the failure using a Python build without sqlite3 support while the default SQLite cache is enabled, then inspect the documented --no-sqlite-cache and configuration settings. Done means mypy no longer raises an INTERNAL ERROR in that environment and the relevant behavior is covered by a test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, sqlite
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100