python / python/mypy

Default mypy configuration crashes on python build without sqlite

Open
#21,440 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

crash topic-configuration topic-incremental
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.