Typing Stubs for six

1.17.0.20260408 · active · verified Thu Apr 09

This package provides typing stubs for the `six` library, enabling static type checking for code that uses `six`. It is part of the community-maintained Typeshed project, which regularly releases updated stubs for third-party packages. The current version, 1.17.0.20260408, aims for compatibility with `six==1.17.*` and is designed for modern Python 3 environments.

Warnings

Install

Imports

Quickstart

This example demonstrates using a common utility from the `six` library (`six.moves.urllib.parse`) and applying type hints from `types-six`. After installing `six`, `types-six`, and a type checker like `mypy`, you can run `mypy example.py` to verify the types. `types-six` ensures that `mypy` understands the types of `six`'s functions and constants, such as `six.text_type`.

import six.moves.urllib.parse

def get_scheme(url: six.text_type) -> six.text_type:
    parsed_url = six.moves.urllib.parse.urlparse(url)
    return parsed_url.scheme

url_str: six.text_type = 'http://example.com/path'
scheme: six.text_type = get_scheme(url_str)
print(f"The scheme is: {scheme}")

# To type-check this:
# 1. pip install six types-six mypy
# 2. Save the code above as example.py
# 3. Run: mypy example.py

view raw JSON →