{"id":22497,"library":"types-peewee","title":"types-peewee","description":"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.","status":"active","version":"4.0.1.20260426","language":"python","source_language":"en","source_url":"https://github.com/python/typeshed","tags":["type-stubs","peewee","typeshed","mypy"],"install":[{"cmd":"pip install types-peewee","lang":"bash","label":"Install stubs"}],"dependencies":[{"reason":"types-peewee provides type hints for peewee; peewee must be installed at runtime.","package":"peewee","optional":false},{"reason":"mypy is the primary type checker that consumes typeshed stubs; other checkers may also work.","package":"mypy","optional":true}],"imports":[{"note":"The stubs declare SqliteDatabase in peewee itself, not in playhouse. Importing from playhouse may cause type errors.","wrong":"from playhouse.sqlite_ext import SqliteDatabase","symbol":"SqliteDatabase","correct":"from peewee import SqliteDatabase"}],"quickstart":{"code":"import os\nfrom peewee import SqliteDatabase, Model, CharField, IntegerField\n\n# Use OS env for auth-like pattern (not needed for SQLite, just for consistency)\ndb_path = os.environ.get('DB_PATH', ':memory:')\ndb = SqliteDatabase(db_path)\n\nclass User(Model):\n    name = CharField()\n    age = IntegerField()\n\n    class Meta:\n        database = db\n\n# This will pass type checks with stubs installed\ndef get_user(name: str) -> User:\n    return User.get(User.name == name)\n","lang":"python","description":"Minimal peewee usage that checks types correctly with types-peewee stubs."},"warnings":[{"fix":"If you encounter missing stubs, consider adding local stub files or using # type: ignore for the affected lines.","message":"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.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure your peewee version matches the stubs version. The stubs are released frequently via typeshed, so upgrade regularly.","message":"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.","severity":"gotcha","affected_versions":"4.0.1.20260426"},{"fix":"No action needed now, but be prepared to switch to a first-party stubs package if peewee adds it.","message":"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.","severity":"deprecated","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run 'pip install types-peewee' and ensure your mypy configuration includes 'typeshed-path' or default stubs.","cause":"types-peewee is not installed or mypy cannot locate it.","error":"Cannot find implementation or library stub for module 'peewee'"},{"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.","cause":"The stubs may be cached or mypy is using a different peewee installation (e.g., from a virtual environment not activated).","error":"peewee installs stub files but mypy still reports 'Module has no attribute \"SqliteDatabase\"'"},{"fix":"Explicitly use keyword arguments matching field definitions, or use '**data' with proper type annotations.","cause":"The stubs expect exact field types. peewee's runtime model allows any kwargs, but stubs are strict.","error":"Argument 1 to \"User\" has incompatible type \"**kwargs\"; expected \"int\" for field \"age\""}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}