types-pysaml2 provides PEP 561 compliant type stubs for the pysaml2 library, enabling static type checking tools like MyPy to validate code that uses pysaml2. It aims to provide accurate type annotations for the current state of pysaml2. Releases are generally infrequent, driven by bug fixes or significant changes in the underlying pysaml2 library.
pip install types-pysaml2Verified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `pysaml2` with the benefits of type checking provided by `types-pysaml2`. Note that `types-pysaml2` itself does not contain runtime code; it merely provides type annotations. To utilize the stubs, you write `pysaml2` code as usual, and `mypy` (or another static type checker) will automatically pick up the annotations provided by `types-pysaml2`.
Install the core library: `pip install pysaml2`.
Upgrade both `pysaml2` and `types-pysaml2` to their latest compatible versions to ensure the most accurate type hints. Check the `types-pysaml2` changelog for specific compatibility notes.
Adjust type annotations and unpacking logic for `LogoutResult` to expect 4 elements (`status`, `reason`, `binding`, `relay_state`). For example, change `status, reason, binding = logout_result` to `status, reason, binding, relay_state = logout_result` in your type hints and code.
Update to `types-pysaml2` v1.0.1 or newer to ensure the correct type hint for `Config.context` is applied during static analysis.