types-bleach provides static type checking stubs for the 'bleach' HTML sanitizing library. It enables type checkers like MyPy or Pyright to validate usage of `bleach` functions and classes without providing any runtime functionality itself. As part of typeshed, these packages are automatically released, potentially up to once a day, reflecting updates to the underlying library's API or improvements in type accuracy.
pip install types-bleachVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use the 'bleach' library. When 'types-bleach' is installed, a static type checker will use its stubs to provide type validation and autocompletion for `bleach` functions like `clean()` and `linkify()`.
Ensure 'bleach' is installed alongside 'types-bleach' (e.g., `pip install bleach types-bleach`). Do not attempt to import modules directly from `types_bleach` at runtime.
It is recommended to pin the version of `types-bleach` to match the major.minor version of your installed `bleach` library, e.g., if `bleach==6.3.0`, use `types-bleach==6.3.0.*`. Additionally, you might consider pinning the full stub version (e.g., `types-bleach==6.3.0.20260408`) if strict type-checking stability is required.
When specifying dependencies, understand that `types-bleach==6.3.0.20260408` means stubs for `bleach` version `6.3.0` released on April 8, 2026. This versioning helps in aligning stubs with the core library version.