Registry / type-stubs / types-werkzeug

types-werkzeug

JSON →
library1.0.9pypypi✓ verified 24d ago

types-werkzeug is a PEP 561 type stub package providing static type annotations for the Werkzeug WSGI utility library. It is used by type-checking tools like MyPy, PyCharm, and Pytype to verify the correctness of code that utilizes Werkzeug. The stubs are sourced from the typeshed project, which automatically releases updates to PyPI, often daily. Note that Werkzeug versions 2.0 and newer include their own inline type annotations, making this stub package redundant for those versions.

pip install types-werkzeug
INSTALL
IMPORT
SIG · TYPES-WERKZEUG
T
types-werkzeug
type-stubspythonv1.0.9
Install
1.6s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.9 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 18MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.000s · 19MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Request
from werkzeug-stubs import Request
from werkzeug.wrappers import Request
Response
from werkzeug-stubs import Response
from werkzeug.wrappers import Response

This example demonstrates a basic Werkzeug application with type annotations. To utilize the `types-werkzeug` stubs, first install `werkzeug`, `types-werkzeug` (if using Werkzeug < 2.0), and a type checker like `mypy`. Then, run `mypy your_app_file.py` to perform static type checking.

import os from werkzeug.wrappers import Request, Response from werkzeug.serving import run_simple @Request.application def application(request: Request) -> Response: """A simple Werkzeug application demonstrating type hints.""" name = request.args.get('name', 'World') return Response(f"Hello, {name}!") if __name__ == "__main__": # This part is for running the server, not directly for type checking. # To check types, save this as `app.py` and run `mypy app.py` # You'd typically need `pip install werkzeug mypy` and optionally `pip install types-werkzeug` # (unless Werkzeug >= 2.0 is used, which has its own types). print("To run the app: http://127.0.0.1:5000/") # run_simple("127.0.0.1", 5000, application)
Debug
Known issues
breakingWerkzeug versions 2.0 and newer ship with their own inline type annotations. If you are using Werkzeug >= 2.0, you should uninstall `types-werkzeug` to avoid conflicts and ensure your type checker uses the native types.
fix
pip uninstall types-werkzeug
affects: Werkzeug >= 2.0
gotcha`types-werkzeug` provides only type hints; it does not include the actual runtime code for Werkzeug. The core `werkzeug` library must be installed alongside `types-werkzeug` for your application to function.
fix
Ensure `pip install werkzeug` is executed in your environment.
affects: < 2.0
gotchaStub package versions are generally tied to the runtime package versions they're meant to type. Using an older `types-werkzeug` with a much newer (or vice-versa) `werkzeug` could lead to inaccurate or incorrect type checking results.
fix
Attempt to keep `types-werkzeug` and `werkzeug` versions in sync, or at least ensure `types-werkzeug` supports the range of your `werkzeug` version. Consult `types-werkzeug` PyPI page for version compatibility notes.
affects: All versions
gotchaFor type checkers like MyPy, sometimes strictness in stubs can expose existing 'type errors' in code that previously passed. Updates to `types-werkzeug` might introduce new checks that break existing type-checking passes.
fix
Address new type errors as they arise; consider pinning `types-werkzeug` to a specific version or range if strict stability is required, but regularly update to benefit from improved type accuracy.
affects: All versions
gotchaWhen using Werkzeug's `abort()` function (often via Flask), MyPy might report issues if the return type is not correctly annotated. This is because type checkers need to understand that `abort()` prevents further execution in the function.
fix
Explicitly add `-> NoReturn` as the return type annotation to functions that call `abort()` to indicate that they never return normally. (e.g., `from typing import NoReturn`)
affects: All versions
Upgrade
Version history
1.0.9latest on PyPI · released Nov 26, 2021
Audit
Dependencies
WerkzeugrequiredProvides runtime functionality; `types-werkzeug` only adds type hints for it. The stubs are useless without the runtime library.
mypyoptionalA type checker is required to utilize the provided type stubs for static analysis.
Agent activity
36 hits · last 30 days
node
30
Amazon
1
OpenAI (training)
1
Resources
types-werkzeug — pip install types-werkzeug · libregistry