types-peewee
raw JSON → 4.0.1.20260426 verified Mon Apr 27 auth: no python
Typing stubs for peewee, provided by typeshed. Version 4.0.1.20260426 corresponds to peewee 4.0.1. These stubs enable static type checking for peewee projects, but they cover a subset of the runtime API and may be incomplete or incorrect for less common features. Release cadence is tied to typeshed releases.
pip install types-peewee Common errors
error Cannot find implementation or library stub for module 'peewee' ↓
cause types-peewee is not installed or mypy cannot locate it.
fix
Run 'pip install types-peewee' and ensure your mypy configuration includes 'typeshed-path' or default stubs.
error peewee installs stub files but mypy still reports 'Module has no attribute "SqliteDatabase"' ↓
cause The stubs may be cached or mypy is using a different peewee installation (e.g., from a virtual environment not activated).
fix
Run 'mypy --no-incremental --cache-dir /dev/null your_script.py' to clear cache. Make sure peewee and types-peewee are installed in the same environment.
error Argument 1 to "User" has incompatible type "**kwargs"; expected "int" for field "age" ↓
cause The stubs expect exact field types. peewee's runtime model allows any kwargs, but stubs are strict.
fix
Explicitly use keyword arguments matching field definitions, or use '**data' with proper type annotations.
Warnings
gotcha The stubs may be incomplete: many peewee methods (especially from playhouse extensions) are not typed. You may see 'Any' or errors when using advanced features like SQLite aggregate functions, FTS, or custom fields. ↓
fix If you encounter missing stubs, consider adding local stub files or using # type: ignore for the affected lines.
gotcha The stubs version is pinned to a specific peewee release (currently 4.0.1). If you use a newer peewee version, some stubs may be out of date and cause false positives or missing type hints. ↓
fix Ensure your peewee version matches the stubs version. The stubs are released frequently via typeshed, so upgrade regularly.
deprecated The types-peewee package is part of the typeshed project, which may eventually be bundled into peewee itself or other distribution mechanisms. Keep an eye on peewee's own type stub support. ↓
fix No action needed now, but be prepared to switch to a first-party stubs package if peewee adds it.
Imports
- SqliteDatabase wrong
from playhouse.sqlite_ext import SqliteDatabasecorrectfrom peewee import SqliteDatabase
Quickstart
import os
from peewee import SqliteDatabase, Model, CharField, IntegerField
# Use OS env for auth-like pattern (not needed for SQLite, just for consistency)
db_path = os.environ.get('DB_PATH', ':memory:')
db = SqliteDatabase(db_path)
class User(Model):
name = CharField()
age = IntegerField()
class Meta:
database = db
# This will pass type checks with stubs installed
def get_user(name: str) -> User:
return User.get(User.name == name)