Type Stubs for pysaml2

1.0.2 · active · verified Mon Apr 13

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.

Warnings

Install

Imports

Quickstart

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`.

import os
from saml2.config import Config
from saml2.client import Saml2Client

def setup_saml_client(config_file_path: str) -> Saml2Client:
    config = Config()
    config.load_file(config_file_path)
    client = Saml2Client(config)
    return client

# Example usage (requires an actual saml2 config file)
# config_path = os.environ.get('SAML2_CONFIG_PATH', 'path/to/saml2/config.xml')
# if os.path.exists(config_path):
#     saml_client = setup_saml_client(config_path)
#     print(f"SAML2 client created with entity ID: {saml_client.config.entityid}")
# else:
#     print(f"Warning: SAML2 config file not found at {config_path}. Quickstart not fully runnable without it.")

# To verify type checking, run mypy on this file after installing types-pysaml2 and pysaml2:
# pip install mypy pysaml2 types-pysaml2
# mypy your_script_name.py

view raw JSON →