Registry / type-stubs / types-markupsafe

types-markupsafe

JSON →
library1.1.10pypypi✓ verified 26d ago

This is a PEP 561 type stub package providing external type annotations for the MarkupSafe library. It enables static type-checking tools like MyPy, PyCharm, or Pyright to analyze code that uses MarkupSafe. The current version is 1.1.10. These stub packages are automatically released by the Typeshed project, ensuring they follow typing specification standards.

pip install types-markupsafe
INSTALL
IMPORT
SIG · TYPES-MARKUPSAFE
T
types-markupsafe
type-stubspythonv1.1.10
Install
1.5s 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.1.10 · 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 · 17.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

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

Markup
from markupsafe_stubs import Markup
from markupsafe_stubs import Markup

This quickstart demonstrates how to install `types-markupsafe` and use a type checker like MyPy to verify the types in code that uses `MarkupSafe`. Note that `types-markupsafe` is only needed for `MarkupSafe` versions prior to 2.0, as newer versions include their own type annotations.

# 1. Install MarkupSafe (if not already present) pip install MarkupSafe==1.1.1 # 2. Install types-markupsafe (for MarkupSafe versions < 2.0) pip install types-markupsafe # 3. Create a Python file (e.g., app.py) to use MarkupSafe # Note: This quickstart is for MarkupSafe < 2.0 from markupsafe import escape, Markup def process_user_input(user_input: str) -> Markup: escaped_input = escape(user_input) return Markup(f"<p>You entered: {escaped_input}</p>") html_output = process_user_input("<script>alert('xss')</script>") print(html_output) # 4. Run a type checker (e.g., MyPy) # pip install mypy # mypy app.py
Debug
Known issues
breakingThe `MarkupSafe` library itself includes type annotations since version 2.0. If you are using `MarkupSafe` 2.0 or newer, you MUST uninstall `types-MarkupSafe` to avoid conflicts and ensure correct type checking, as `types-MarkupSafe` is intended for `MarkupSafe` versions older than 2.0.
fix
Uninstall `types-markupsafe` using `pip uninstall types-markupsafe`. Keep `markupsafe` installed.
affects: MarkupSafe >= 2.0
gotchaEnsure the version of `types-markupsafe` you install is compatible with your installed `markupsafe` version. The `types-markupsafe` version number (excluding the last part) aims to match the `markupsafe` version it provides stubs for. `types-markupsafe 1.1.x` is for `markupsafe 1.1.x`.
fix
Pin `types-markupsafe` to a version compatible with your `markupsafe` installation. For `markupsafe < 2.0`, typically `types-markupsafe` matches the minor version.
affects: All versions
gotcha`types-markupsafe` is a stub-only package and provides no runtime functionality. It should not be imported directly in your application code, nor does it expose any objects or functions at runtime. Its sole purpose is to be consumed by static type checkers.
fix
Do not attempt to import from or use `types-markupsafe` in your Python code. Continue to import `Markup` and `escape` from `markupsafe`.
affects: All versions
Upgrade
Version history
1.1.10latest on PyPI · released Nov 27, 2021
Audit
Dependencies
MarkupSafeoptionalProvides type stubs for the MarkupSafe library; MarkupSafe itself must be installed to be type-checked.
Agent activity
26 hits · last 30 days
node
24
OpenAI (training)
1
Resources
types-markupsafe — pip install types-markupsafe · libregistry