# Typing

**URL:** https://discuss.python.org/c/typing/32.md

[Latest](https://discuss.python.org/latest.md) · [Categories](https://discuss.python.org/categories.md) · [Tags](https://discuss.python.org/tags.md)

---

## [About the Typing category](https://discuss.python.org/t/about-the-typing-category/34155)

<div class="topic-metadata">

**Author:** [@brettcannon](https://discuss.python.org/u/brettcannon)\
**Replies:** 2\
**Last updated:** [October 17, 2023, 10:24am UTC](https://discuss.python.org/t/about-the-typing-category/34155 "2023-10-17T10:24:11Z")

</div>

Discussions involving typing in Python. Previously this was the typing-sig mailing list.

---

## [Should non-generic classes with \`\_\_class\_getitem\_\_\` be subscriptable in a type expression?](https://discuss.python.org/t/should-non-generic-classes-with-class-getitem-be-subscriptable-in-a-type-expression/108666)

<div class="topic-metadata">

**Author:** [@carljm](https://discuss.python.org/u/carljm)\
**Replies:** 40\
**Last updated:** [September 28, 2026, 4:20pm UTC](https://discuss.python.org/t/should-non-generic-classes-with-class-getitem-be-subscriptable-in-a-type-expression/108666 "2026-09-28T16:20:21Z")

</div>

The AstroPy library documents a suggested pattern to type-annotate using an expression like Quantity\[u.km\]. Quantity is not a generic class, but it implements \_\_class\_getitem\_\_ to return Annotated\[Quantity, u.km\] – effec…

---

## [Make \_\_replace\_\_ stop interfering with variance inference](https://discuss.python.org/t/make-replace-stop-interfering-with-variance-inference/96092)

<div class="topic-metadata">

**Author:** [@NeilGirdhar](https://discuss.python.org/u/NeilGirdhar)\
**Replies:** 44\
**Last updated:** [September 27, 2026, 10:07pm UTC](https://discuss.python.org/t/make-replace-stop-interfering-with-variance-inference/96092 "2026-09-27T22:07:08Z")

</div>

Consider: from dataclasses import dataclass from typing import Generic, TypeVar, override if False: # Switch to True is a type error. @dataclass(frozen=True) class C\[T\]: x: T # T is inferred to be in…

---

## [Pulse check on Intersections draft work](https://discuss.python.org/t/pulse-check-on-intersections-draft-work/109087)

<div class="topic-metadata">

**Author:** [@mikeshardmind](https://discuss.python.org/u/mikeshardmind)\
**Replies:** 36\
**Last updated:** [September 25, 2026, 11:53am UTC](https://discuss.python.org/t/pulse-check-on-intersections-draft-work/109087 "2026-09-25T11:53:12Z")

</div>

I’m nearing readiness to start working on finding a typechecker to work with on a reference implementation + a PEP proposal. I’d like to check with the community to make sure the behavior of 2 specific cases is somethin…

---

## [Typing Meetup: Call for topics in October or November](https://discuss.python.org/t/typing-meetup-call-for-topics-in-october-or-november/109163)

<div class="topic-metadata">

**Author:** [@stroxler](https://discuss.python.org/u/stroxler)\
**Replies:** 2\
**Last updated:** [September 23, 2026, 11:43pm UTC](https://discuss.python.org/t/typing-meetup-call-for-topics-in-october-or-november/109163 "2026-09-23T23:43:42Z")

</div>

Hi all! I’d like to hold another zoom typing meetup in October or November if there are topics folks would like to discuss. If you’re interested in presenting, please reply in this thread. Cc @rchen152 , @Jelle , @davi…

---

## [Draft PEP: More Expressive Type Expressions](https://discuss.python.org/t/draft-pep-more-expressive-type-expressions/108856)

<div class="topic-metadata">

**Author:** [@ImogenBits](https://discuss.python.org/u/ImogenBits)\
**Replies:** 13\
**Last updated:** [September 21, 2026, 10:00pm UTC](https://discuss.python.org/t/draft-pep-more-expressive-type-expressions/108856 "2026-09-21T22:00:06Z")

</div>

This is a continuation of my previous post on this topic. I’ve decided to make this a new thread since the ideas have been refocused a lot since then and my goal now is to essentially make a new run down of the problem a…

---

## [Conditional imports in stub files](https://discuss.python.org/t/conditional-imports-in-stub-files/50326)

<div class="topic-metadata">

**Author:** [@srittau](https://discuss.python.org/u/srittau)\
**Replies:** 6\
**Last updated:** [September 19, 2026, 1:45pm UTC](https://discuss.python.org/t/conditional-imports-in-stub-files/50326 "2026-09-19T13:45:31Z")

</div>

This came up during the transition from types-Pillow to inline annotations in Pillow. See Depend on Pillow instead of types-Pillow by srittau · Pull Request #11720 · python/typeshed · GitHub. The Package python-xlib has…

---

## [Suggestion: add a typing.safe\_cast() function, which just does assert isinstance(x, T)](https://discuss.python.org/t/suggestion-add-a-typing-safe-cast-function-which-just-does-assert-isinstance-x-t/109081)

<div class="topic-metadata">

**Author:** [@noamraph](https://discuss.python.org/u/noamraph)\
**Replies:** 9\
**Last updated:** [September 17, 2026, 2:38pm UTC](https://discuss.python.org/t/suggestion-add-a-typing-safe-cast-function-which-just-does-assert-isinstance-x-t/109081 "2026-09-17T14:38:55Z")

</div>

I’m regularly defining this function, which helps make my code shorter and easier to read. I think it may be a good idea to add something like this to the typing module: def safe\_cast\[T\](t: type\[T\], x: object) -\> T: …

---

## [ParamSpec on overloaded & generic functions](https://discuss.python.org/t/paramspec-on-overloaded-generic-functions/109091)

<div class="topic-metadata">

**Author:** [@decorator-factory](https://discuss.python.org/u/decorator-factory)\
**Replies:** 0\
**Last updated:** [September 17, 2026, 3:17am UTC](https://discuss.python.org/t/paramspec-on-overloaded-generic-functions/109091 "2026-09-17T03:17:29Z")

</div>

Some thoughts on how ParamSpec interacts with generic and overloaded functions. Generic functions First example, with a generic function (works in mypy, pyright, ty, pyrefly, but not zuban): from collections.abc import…

---

## [\_ProtocolMeta: why? Can it be removed?](https://discuss.python.org/t/protocolmeta-why-can-it-be-removed/108813)

<div class="topic-metadata">

**Author:** [@jacopoabramo](https://discuss.python.org/u/jacopoabramo)\
**Replies:** 4\
**Last updated:** [September 16, 2026, 9:17am UTC](https://discuss.python.org/t/protocolmeta-why-can-it-be-removed/108813 "2026-09-16T09:17:21Z")

</div>

Having a look at typing.Protocol, this seems to depend on a metatype \_ProtocolMeta. From the main branch of the CPython repository, this is what it’s reported: class \_ProtocolMeta(ABCMeta): # This metaclass is some…

---

## [2026 Python Type System and Tooling Survey is out!](https://discuss.python.org/t/2026-python-type-system-and-tooling-survey-is-out/108426)

<div class="topic-metadata">

**Author:** [@grievejia](https://discuss.python.org/u/grievejia)\
**Replies:** 4\
**Last updated:** [September 2, 2026, 5:27pm UTC](https://discuss.python.org/t/2026-python-type-system-and-tooling-survey-is-out/108426 "2026-09-02T17:27:04Z")

</div>

The 2026 Python Type System and Tooling Survey is out! Take the survey here: Python Type System and Tooling Survey 2026 (or scan the QR code attached at the end). I also want to say a huge thank-you to the folks who co…

---

## [Idea: Simpler and More Expressive Type Annotations](https://discuss.python.org/t/idea-simpler-and-more-expressive-type-annotations/104730)

<div class="topic-metadata">

**Author:** [@ImogenBits](https://discuss.python.org/u/ImogenBits)\
**Replies:** 84\
**Last updated:** [September 2, 2026, 3:21pm UTC](https://discuss.python.org/t/idea-simpler-and-more-expressive-type-annotations/104730 "2026-09-02T15:21:07Z")

</div>

Something that comes up occasionally is that type annotations are somewhat verbose and limited in functionality. For example, the recent discussion around an inline typed dict syntax is heavily constrained by the fact th…

---

## [Class \`date\` is unsafe in typed Python](https://discuss.python.org/t/class-date-is-unsafe-in-typed-python/107590)

<div class="topic-metadata">

**Author:** [@maciek](https://discuss.python.org/u/maciek)\
**Replies:** 1\
**Last updated:** [September 2, 2026, 9:20am UTC](https://discuss.python.org/t/class-date-is-unsafe-in-typed-python/107590 "2026-09-02T09:20:30Z")

</div>

Hello, I’d like to discuss adding an optional mypy feature that rejects unsafe subtype-based usage between date and datetime. Currently the following code passes type checking but raises TypeError at runtime: from dat…

---

## [Permitting more precise inferred types from ambiguous overloads](https://discuss.python.org/t/permitting-more-precise-inferred-types-from-ambiguous-overloads/108776)

<div class="topic-metadata">

**Author:** [@carljm](https://discuss.python.org/u/carljm)\
**Replies:** 19\
**Last updated:** [September 1, 2026, 10:30pm UTC](https://discuss.python.org/t/permitting-more-precise-inferred-types-from-ambiguous-overloads/108776 "2026-09-01T22:30:31Z")

</div>

The typing spec and conformance suite currently require that if overload resolution is ambiguous due to gradual argument types, the return type must be inferred as Any. This is motivated by maintaining graduality of inp…

---

## [Proposal: \`typing.no\_discard\`, a decorator to indicate that the return value should not be discarded](https://discuss.python.org/t/proposal-typing-no-discard-a-decorator-to-indicate-that-the-return-value-should-not-be-discarded/33138)

<div class="topic-metadata">

**Author:** [@kwsp](https://discuss.python.org/u/kwsp)\
**Replies:** 54\
**Last updated:** [August 30, 2026, 6:20am UTC](https://discuss.python.org/t/proposal-typing-no-discard-a-decorator-to-indicate-that-the-return-value-should-not-be-discarded/33138 "2026-08-30T06:20:14Z")

</div>

Moving this discussion in a new direction In Python, there is no way to enforce a return value from a function/method is used. This is especially useful for functions and methods that are pure (i.e. the function has no …

---

## [Spec change proposal: updating/clarifying rules for unpacking TypedDicts in function calls](https://discuss.python.org/t/spec-change-proposal-updating-clarifying-rules-for-unpacking-typeddicts-in-function-calls/108582)

<div class="topic-metadata">

**Author:** [@yangdanny97](https://discuss.python.org/u/yangdanny97)\
**Replies:** 17\
**Last updated:** [August 28, 2026, 3:31am UTC](https://discuss.python.org/t/spec-change-proposal-updating-clarifying-rules-for-unpacking-typeddicts-in-function-calls/108582 "2026-08-28T03:31:04Z")

</div>

Previously, this section of the spec was not asserted in conformance tests or implemented by any type checkers: Callables — typing documentation I propose a change to the typing spec and conformance tests to update the …

---

## [Deprecate function arguments](https://discuss.python.org/t/deprecate-function-arguments/103672)

<div class="topic-metadata">

**Author:** [@oliversheridanmethven](https://discuss.python.org/u/oliversheridanmethven)\
**Replies:** 6\
**Last updated:** [August 26, 2026, 5:06pm UTC](https://discuss.python.org/t/deprecate-function-arguments/103672 "2026-08-26T17:06:45Z")

</div>

Based on this ticket I raised on mypy: Support for deprecating function arguments · Issue #19817 · python/mypy · GitHub (While the below names mypy, this extends to other type checkers. ) Feature Currently we can depr…

---

## [Using classes as \`dataclass\_transform\` \`field\_specifiers\`](https://discuss.python.org/t/using-classes-as-dataclass-transform-field-specifiers/46459)

<div class="topic-metadata">

**Author:** [@bradleyharden](https://discuss.python.org/u/bradleyharden)\
**Replies:** 7\
**Last updated:** [August 20, 2026, 3:48pm UTC](https://discuss.python.org/t/using-classes-as-dataclass-transform-field-specifiers/46459 "2026-08-20T15:48:21Z")

</div>

According to dataclass\_transform decorator specification, the field\_specifiers argument takes a static tuple of functions or classes. The current specification explicitly mentions classes on multiple occasions: field\_s…

---

## [Proposal: more kinds of Callable types](https://discuss.python.org/t/proposal-more-kinds-of-callable-types/108648)

<div class="topic-metadata">

**Author:** [@laund](https://discuss.python.org/u/laund)\
**Replies:** 20\
**Last updated:** [August 19, 2026, 10:22pm UTC](https://discuss.python.org/t/proposal-more-kinds-of-callable-types/108648 "2026-08-19T22:22:57Z")

</div>

Summary I propose adding different variants of Callable to typing or other relevant parts of the stdlib, which use the same syntax as Callable but allow differentiating between different kinds of callables which may have…

---

## [Spec: metaclass constructors](https://discuss.python.org/t/spec-metaclass-constructors/108357)

<div class="topic-metadata">

**Author:** [@Viicos](https://discuss.python.org/u/Viicos)\
**Replies:** 1\
**Last updated:** [August 17, 2026, 7:50pm UTC](https://discuss.python.org/t/spec-metaclass-constructors/108357 "2026-08-17T19:50:04Z")

</div>

Thanks to @erictraut’s work, instance constructors are specified in this chapter. I’d like to extend this chapter for metaclass constructors. Thankfully, it mostly follows the same rules, but needs some extra information…

---

## [Define a variadic return value](https://discuss.python.org/t/define-a-variadic-return-value/108446)

<div class="topic-metadata">

**Author:** [@ZeeD](https://discuss.python.org/u/ZeeD)\
**Replies:** 3\
**Last updated:** [August 11, 2026, 2:21pm UTC](https://discuss.python.org/t/define-a-variadic-return-value/108446 "2026-08-11T14:21:20Z")

</div>

Hi. I’m struggling trying to define a function that takes multiple parameters and build a tuple with “dependant” types. Here a (very simplified) scenario class C1: def \_\_init\_\_(self, foo: str) -\> None: ... class C…

---

## [Clarifying that type checkers should not emit diagnostics in \`if not TYPE\_CHECKING\`](https://discuss.python.org/t/clarifying-that-type-checkers-should-not-emit-diagnostics-in-if-not-type-checking/106902)

<div class="topic-metadata">

**Author:** [@carljm](https://discuss.python.org/u/carljm)\
**Replies:** 14\
**Last updated:** [August 8, 2026, 6:05am UTC](https://discuss.python.org/t/clarifying-that-type-checkers-should-not-emit-diagnostics-in-if-not-type-checking/106902 "2026-08-08T06:05:52Z")

</div>

It came up recently that the conformance suite asserts that type checkers should not emit diagnostics in if not TYPE\_CHECKING blocks (or the else clause of if TYPE\_CHECKING blocks), but this is not clearly specified anyw…

---

## [Proposal: allow chaining @final decorator when previous decorators return a non-function](https://discuss.python.org/t/proposal-allow-chaining-final-decorator-when-previous-decorators-return-a-non-function/78918)

<div class="topic-metadata">

**Author:** [@samwgoldman](https://discuss.python.org/u/samwgoldman)\
**Replies:** 5\
**Last updated:** [August 7, 2026, 9:10am UTC](https://discuss.python.org/t/proposal-allow-chaining-final-decorator-when-previous-decorators-return-a-non-function/78918 "2026-08-07T09:10:40Z")

</div>

Currently, the typing spec for @final (link) states: It is an error to use \`@final\` on a non-method function. I think this restriction makes sense, as we have capital-F Final for attributes, including property descript…

---

## [Spec change: Do not require an error for a generic class attribute](https://discuss.python.org/t/spec-change-do-not-require-an-error-for-a-generic-class-attribute/108456)

<div class="topic-metadata">

**Author:** [@Jelle](https://discuss.python.org/u/Jelle)\
**Replies:** 1\
**Last updated:** [August 7, 2026, 9:08am UTC](https://discuss.python.org/t/spec-change-do-not-require-an-error-for-a-generic-class-attribute/108456 "2026-08-07T09:08:58Z")

</div>

The conformance suite currently requires an error for this code: from typing import Any, TypeVar, Generic, assert\_type T = TypeVar("T") class Node(Generic\[T\]): label: T def \_\_init\_\_(self, label: T | None = Non…

---

## [Call for Typing Council nominations – July 2026](https://discuss.python.org/t/call-for-typing-council-nominations-july-2026/108197)

<div class="topic-metadata">

**Author:** [@Jelle](https://discuss.python.org/u/Jelle)\
**Replies:** 7\
**Last updated:** [August 6, 2026, 12:20am UTC](https://discuss.python.org/t/call-for-typing-council-nominations-july-2026/108197 "2026-08-06T00:20:29Z")

</div>

@JukkaL is planning to step down from the Typing Council. Quoting from PEP 729: If there is a vacancy and there are three or more remaining members, it is up to the Council to decide whether to appoint a new member. To…

---

## [Looking for draft feedback: Python Typing Survey 2026](https://discuss.python.org/t/looking-for-draft-feedback-python-typing-survey-2026/108255)

<div class="topic-metadata">

**Author:** [@grievejia](https://discuss.python.org/u/grievejia)\
**Replies:** 18\
**Last updated:** [August 5, 2026, 5:17pm UTC](https://discuss.python.org/t/looking-for-draft-feedback-python-typing-survey-2026/108255 "2026-08-05T17:17:18Z")

</div>

Hi all, The Python Typing Survey is back for its third year! Last year we received 1,241 responses (up 15% YoY), and we’ve been pleased to see the survey become a recognised reference point for the direction of Python’s…

---

## [How to decide when to use typing.IO or io.IOBase?](https://discuss.python.org/t/how-to-decide-when-to-use-typing-io-or-io-iobase/108384)

<div class="topic-metadata">

**Author:** [@xuxinhang](https://discuss.python.org/u/xuxinhang)\
**Replies:** 2\
**Last updated:** [August 4, 2026, 3:24am UTC](https://discuss.python.org/t/how-to-decide-when-to-use-typing-io-or-io-iobase/108384 "2026-08-04T03:24:12Z")

</div>

I notice there are “two series” of IO stream-style interface provide by Python standard library, which are typing.IO, including BinaryIO and TextIO io.IOBase, including RawIOBase, TextIOBase etc. IOBase is good at fun…

---

## [Treat Literal of all elements of enum equal to the enum in type annotations](https://discuss.python.org/t/treat-literal-of-all-elements-of-enum-equal-to-the-enum-in-type-annotations/108317)

<div class="topic-metadata">

**Author:** [@JoniKauf](https://discuss.python.org/u/JoniKauf)\
**Replies:** 6\
**Last updated:** [July 30, 2026, 11:32am UTC](https://discuss.python.org/t/treat-literal-of-all-elements-of-enum-equal-to-the-enum-in-type-annotations/108317 "2026-07-30T11:32:20Z")

</div>

Would it be reasonable to define in the typing specification that that a literal of all elements of an enum should be treated equally to the enum itself in type annotations? For example: import enum import typing as t …

---

## [Typing Meetup: July 22nd, 2026 10am PDT](https://discuss.python.org/t/typing-meetup-july-22nd-2026-10am-pdt/107858)

<div class="topic-metadata">

**Author:** [@stroxler](https://discuss.python.org/u/stroxler)\
**Replies:** 3\
**Last updated:** [July 23, 2026, 6:07pm UTC](https://discuss.python.org/t/typing-meetup-july-22nd-2026-10am-pdt/107858 "2026-07-23T18:07:12Z")

</div>

With the run up to the typing summit it’s been a while since we had a Python typing meetup. I’d like to host on Wednesday, July 22nd at 10am PDT (see link for local times + zoom). We have one topic from Pyrefly - Zeina …

---

## [\[withdrawn\] A decorator to mark AI-assisted code](https://discuss.python.org/t/withdrawn-a-decorator-to-mark-ai-assisted-code/108248)

<div class="topic-metadata">

**Author:** [@yuan-shuo](https://discuss.python.org/u/yuan-shuo)\
**Replies:** 5\
**Last updated:** [July 23, 2026, 9:45am UTC](https://discuss.python.org/t/withdrawn-a-decorator-to-mark-ai-assisted-code/108248 "2026-07-23T09:45:30Z")

</div>

Withdrawn This proposal has been withdrawn. After feedback from the community — I realize this is a workflow/process concern rather than something Python’s standard library should solve. The reviewed=False API in particu…

[Next page](https://discuss.python.org/c/typing/32.md?page=1)
