types-bleach
Typing stubs for bleach
What it is and what it does
types-bleach is a type stub package that provides static type information for the bleach HTML sanitization library. It allows type checkers like mypy, pyright, and ty to understand and validate code that calls bleach functions, catching type errors at development time rather than runtime. The stubs are maintained as part of the typeshed project and are generated from the official typeshed repository.
This package is a pure typing aid—it contains no runtime code and does not replace bleach itself. It is useful when you want strict type checking in projects that use bleach but do not want to add bleach as a direct dependency to your type-checking environment, or when bleach does not yet ship its own inline type hints. The package depends on types-html5lib to provide types for bleach's HTML parsing dependency.
Use it for:
- Add type checking to a project that uses bleach for HTML sanitization without installing bleach in your type-checking environment.
- Validate bleach function calls and return types in a mypy or pyright configuration before runtime.
- Ensure type safety when passing user input through bleach.clean() or other bleach sanitization functions.
- Integrate bleach into a strictly typed codebase that enforces type checking in CI/CD pipelines.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides type stubs for the bleach HTML sanitization library, enabling static type checkers to validate code that uses bleach without requiring the library itself to be installed.
Yes, if you use bleach and want static type checking. Install it alongside your type checker (mypy, pyright, or ty) in development or CI environments. The package is lightweight, actively maintained, has no known vulnerabilities, and carries a permissive license. It is only useful if you are already using a static type checker; it adds no runtime value.
Install
types-bleach on PyPI
pip
pip install types-bleachuv
uv add types-bleachpoetry
poetry add types-bleachInstalling types-bleach
Before you install
Low friction installation with a single runtime dependency on types-html5lib. The package is actively maintained with a recent release and no known vulnerabilities.
License in practice
Licensed under Apache-2.0 (permissive), allowing use in most commercial and open-source projects without significant restrictions.
Quickstart
pip install types-bleach
# In your code, type checkers will now understand bleach imports:
import bleach
result: str = bleach.clean('<p>Hello</p>')
Requires Python 3.10 or later; type stubs are only useful when used with a type checker like mypy, pyright, or ty.
Verify before relying
- Whether the stubs cover all bleach 6.4.* APIs or only a subset of the public surface.
- Whether installing this package is necessary or if bleach itself now ships inline type hints.
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — types-html5lib |
| Maintenance | actively maintained — 17 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,849,346/month — #3,493 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: types_bleach-6.4.0.20260728-py3-none-any.whl
Tags
More Quality Assurance packages
Coverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
ruffRuff is a Python linter and code formatter…
permissive · top 1,000 on PyPI
pexpectPexpect spawns and controls interactive console…
permissive · top 1,000 on PyPI
blackBlack reformats Python source code to a…
permissive · top 1,000 on PyPI
pytest-xdistpytest-xdist distributes pytest tests across…
permissive · top 1,000 on PyPI
cfn-lintValidates AWS CloudFormation templates in YAML…
permissive · top 1,000 on PyPI
types-boltonsProvides type stubs for the boltons library,…
permissive · top 15,000 on PyPI
types-DeprecatedProvides type stubs for the Deprecated package,…
permissive · top 5,000 on PyPI
types-shapelyProvides type stubs for the shapely package,…
permissive · top 15,000 on PyPI
types-dateparserProvides type stubs for the dateparser package,…
permissive · top 5,000 on PyPI
types-yt-dlpProvides type hints for yt-dlp, enabling static…
permissive · top 15,000 on PyPI
types-gunicornProvides type stubs for gunicorn to enable…
permissive · top 15,000 on PyPI
bleachBleach sanitizes untrusted HTML by escaping or…
permissive · top 1,000 on PyPI
bleach-allowlistProvides curated allowlists of HTML tags,…
permissive · top 5,000 on PyPI
types-pyflakesProvides type stubs for the pyflakes static…
permissive · top 15,000 on PyPI
types-antlr4-python3-runtimeProvides type stubs for antlr4-python3-runtime,…
permissive · top 15,000 on PyPI