> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Python Never

`typing.Never` is the bottom type in Python's static type system. Introduced in Python 3.11 (PEP 673), it represents a type that contains no values. Because it has no instances, a variable or parameter annotated with `Never` can never be assigned a value at runtime without violating static type constraints.

In type theory, a bottom type is the strict subtype of all other types. This means `Never` is implicitly compatible with `int`, `str`, `list`, or any user-defined class. It is the structural inverse of `object`, which is the true top type (the strict supertype of all types). This contrasts with `typing.Any`, which is the dynamic type that bypasses type checking by acting as both a supertype and a subtype to all types to facilitate gradual typing.

```python theme={"dark"}
from typing import Never


# Syntactic application in a function signature
def terminate_process() -> Never:
    raise SystemExit(1)


# Syntactic application in variable annotation

# (Static type checkers will flag any assignment to this variable as an error)
impossible_state: Never
```

## Exhaustiveness Checking

The primary application of `Never` in static type analysis is exhaustiveness checking. Using the `typing.assert_never()` function, developers can statically verify that all possible cases in a `match` statement or a `Union` have been handled.

`assert_never()` is typed to accept an argument of type `Never`. If a type checker determines that a branch of code is reachable (meaning the variable has not been narrowed down to `Never`), passing that variable to `assert_never()` will trigger a static type error.

```python theme={"dark"}
from typing import assert_never

def process_value(val: int | str) -> None:
    match val:
        case int():
            print("Handling integer")
        case str():
            print("Handling string")
        case _:
            # Static type checkers verify 'val' is narrowed to 'Never' here.
            # If the function signature expands to `int | str | float`, 
            # 'val' would be 'float' here, and assert_never() would flag an error.
            assert_never(val)
```

## Relationship with `NoReturn`

`Never` and `typing.NoReturn` are treated as strictly equivalent by static type checkers (such as `mypy` or `pyright`). They share the exact same internal semantics.

`Never` was introduced to provide a more mathematically accurate and context-independent name for the bottom type. While `NoReturn` conceptually implies a function's return signature (indicating a function that halts execution or loops infinitely), `Never` is semantically appropriate for any type hint context, including variable annotations, argument types, and generic type parameters.

## Structural Properties

* **Uninstantiable:** There is no valid Python object that satisfies the `Never` type.
* **Universal Subtype:** Because it is the bottom type, a function returning `Never` can be safely used in contexts expecting a function returning any other type (e.g., `Callable[[], int]` can accept a `Callable[[], Never]`).
* **Intersection Identity:** In type algebra, the intersection of any type `T` and `Never` evaluates to `Never`.
* **Union Identity:** The union of any type `T` and `Never` evaluates to `T` (e.g., `Union[int, Never]` simplifies to `int`).

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor Python Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
