mailwal

πŸπŸš€ [3.15] better typing

Rodrigo | Mathspp

October 27, 2026

πŸπŸš€ [3.15] better typing

day 11 of 15 days of Python 3.15

Hey there, πŸ‘‹

How is your Python 🐍 going?

In this email we’ll talk about the improvements made to typing in 3.15. πŸš€

Python 3.15 logo. Purple heart in the background with two symmetrical snakes, yellow and blue, in front. Some release highlights frame the whole logo. Logo by Marie Nordin and Georgi Ker.

See the future schedule here and links to the previous days: https://mathspp.com/python-315

Typing keeps getting better

Since static type hinting started in Python 3.5, every Python release brings with it improvements.

Here’s a rundown of some of those.

Better TypedDict

TypedDict can now have extra items or it can be set to close to completely disallow extra items, regardless of their type.

This was covered yesterday and you can learn more here.

Improved TypeVarTuple

A type variable can be set to be bound to another type, or you can explicitly set its variance.

This is done when creating type variables manually:

from typing import TypeVar

T1 = TypeVar("T1")
T2 = TypeVar("T2", bound=str)
T3 = TypeVar("T3", covariant=True)
T4 = TypeVar("T4", contravariant=True)
T5 = TypeVar("T5", infer_variance=True)

In Python 3.15, the interface of TypeVarTuple was expanded to also accept these keyword arguments.

The goal is to have TypeVar and TypeVarTuple with the same interface.

This means you can control the variance of a type variable tuple.

For the argument bound, the meaning of setting bound is yet to be defined.

Instance and subclass checks with protocols

Protocols can be used with isinstance and issubclass if you decorate them with @typing.runtime_checkable.

This property is not inherited.

Thus, in Python 3.15 it’s now deprecated to use isinstance and issubclass with protocols that inherit from runtime checkable protocols but that aren’t themselves marked as being runtime checkable.

This means fewer errors will slip through the cracks.

Meta-typing features

Python 3.15 also introduces TypeForm and @disjoint_base, two features that are more niche and typically directed at code that works with types at a higher level.

TypeForm can be used to annotate type form objects (like int, "bool", str | int, or list[bool]).

disjoint_base is used to decorate classes that can’t be inherited from simultaneously.

Further reading

You can learn more about each new feature by reading the full article here: https://mathspp.com/blog/typing-improvements-in-python-315

Tomorrow you’ll learn about other nice things added to the standard library in Python 3.15.

See the future schedule here and links to the previous days: https://mathspp.com/python-315

tw
yt
in

You received this email (at [subscriber]) because you got my free Python book β€œPydon’ts” or one of my other books/cheatsheets (or because you signed up directly!).

Rodrigo πŸπŸš€

Β© 2026 mathspp insider πŸπŸš€

228 Park Ave S, #29976, New York, New York 10003, United States