# python/typing_extensions architecture

> Architecture diagram of the GitHub repository python/typing_extensions, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/python/typing_extensions
- Repository: https://github.com/python/typing_extensions

## Overview

##### Main Components

a) Core Components:
- Typing Extensions Module
- Main implementation (typing_extensions.py)
- Test helpers (_typed_dict_test_helper.py)
- Test suite (test_typing_extensions.py)

b) Integration Components:
- Python's Built-in Typing Module (external dependency)
- Static Type Checkers (external integrations like mypy and pyright)

**Top Layer: Type Checker Integration**

**Middle Layer: Typing Extensions Implementation**

**Bottom Layer: Python Standard Library Typing**

##### Key Elements to Highlight

a) Module Relationships:
- Integration points with static type checkers
- Version compatibility flows

b) Feature Categories:
- Features by Python version compatibility
- Separate experimental features from backported features

**┌─────────────────────────────────────┐**
- Type Checkers             │
- (mypy, pyright, others...)       │
- ┘
- ↑
**┌─────────────────────────────────────┐**
- Typing Extensions Module        │

- ┌─────────────┐    ┌────────────┐  │
- Feature   │    │  Feature   │  │
- Backports   │    │Experiments │  │
- ┘    └────────────┘  │
- ┘
- ↑
**┌─────────────────────────────────────┐**
- Python Standard Typing          │
- ┘

##### Important Details

- Version compatibility matrix
- Feature flow from experimental to standard library
- Test coverage relationship
- Documentation generation flow
- CI/CD pipeline integration

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Type Checker Integration"
        TC1["mypy"]:::typechecker
        TC2["pyright"]:::typechecker
        TC3["other checkers"]:::typechecker
    end

    subgraph "Typing Extensions Module"
        TE["Main Implementation"]:::core
        click TE "https://github.com/python/typing_extensions/blob/main/src/typing_extensions.py"
        
        subgraph "Features"
            FB["Backported Features"]:::feature
            FE["Experimental Features"]:::feature
        end
        
        subgraph "Testing Components"
            TH["Test Helpers"]:::test
            click TH "https://github.com/python/typing_extensions/blob/main/src/_typed_dict_test_helper.py"
            TS["Test Suite"]:::test
            click TS "https://github.com/python/typing_extensions/blob/main/src/test_typing_extensions.py"
        end
        
        subgraph "Documentation"
            DM["Main Docs"]:::doc
            click DM "https://github.com/python/typing_extensions/blob/main/doc/index.rst"
            DC["Doc Config"]:::doc
            click DC "https://github.com/python/typing_extensions/blob/main/doc/conf.py"
            DE["Doc Extensions"]:::doc
            click DE "https://github.com/python/typing_extensions/tree/main/doc/_extensions/"
        end
        
        subgraph "Development Tools"
            PV["Package Verification"]:::tool
            click PV "https://github.com/python/typing_extensions/blob/main/scripts/check_package.py"
            TR["Test Requirements"]:::tool
            click TR "https://github.com/python/typing_extensions/blob/main/test-requirements.txt"
            BC["Build Config"]:::tool
            click BC "https://github.com/python/typing_extensions/blob/main/pyproject.toml"
        end
        
        subgraph "CI/CD"
            CI["CI Workflow"]:::cicd
            click CI "https://github.com/python/typing_extensions/blob/main/.github/workflows/ci.yml"
            PW["Publishing Workflow"]:::cicd
            click PW "https://github.com/python/typing_extensions/blob/main/.github/workflows/publish.yml"
            TI["Third-party Integration"]:::cicd
            click TI "https://github.com/python/typing_extensions/blob/main/.github/workflows/third_party.yml"
        end
        
        subgraph "Project Docs"
            CL["Changelog"]:::projectdoc
            click CL "https://github.com/python/typing_extensions/blob/main/CHANGELOG.md"
            CG["Contributing Guidelines"]:::projectdoc
            click CG "https://github.com/python/typing_extensions/blob/main/CONTRIBUTING.md"
            SP["Security Policy"]:::projectdoc
            click SP "https://github.com/python/typing_extensions/blob/main/SECURITY.md"
            RM["README"]:::projectdoc
            click RM "https://github.com/python/typing_extensions/blob/main/README.md"
        end
    end

    subgraph "Python Standard Library"
        PST["typing module"]:::stdlib
    end

    %% Relationships
    PST --> TE
    TE --> TC1 & TC2 & TC3
    TE --> FB & FE
    FB & FE --> TH & TS
    TE --> DM
    PV --> TE
    CI --> TE
    PW --> TE
    TI --> TE

    %% Styles
    classDef core fill:#e1f5fe,stroke:#0288d1,stroke-width:2px
    classDef feature fill:#f1f8e9,stroke:#689f38,stroke-width:2px
    classDef test fill:#f5f5f5,stroke:#9e9e9e,stroke-width:2px
    classDef doc fill:#fff3e0,stroke:#ff9800,stroke-width:2px
    classDef tool fill:#e8eaf6,stroke:#3f51b5,stroke-width:2px
    classDef cicd fill:#fce4ec,stroke:#e91e63,stroke-width:2px
    classDef projectdoc fill:#f3e5f5,stroke:#9c27b0,stroke-width:2px
    classDef stdlib fill:#fff8e1,stroke:#ffa000,stroke-width:2px
    classDef typechecker fill:#e8f5e9,stroke:#43a047,stroke-width:2px,stroke-dasharray: 5 5

    %% Legend
    subgraph Legend
        L1["Core Component"]:::core
        L2["Feature"]:::feature
        L3["Testing"]:::test
        L4["Documentation"]:::doc
        L5["Development Tool"]:::tool
        L6["CI/CD"]:::cicd
        L7["Project Documentation"]:::projectdoc
        L8["Standard Library"]:::stdlib
        L9["Type Checker"]:::typechecker
    end
```
