# PEP 724: Stricter Type Guards

**URL:** <https://discuss.python.org/t/pep-724-stricter-type-guards/34124>\
**Category:** PEPs\
**Tags:** typing\
**Created:** [September 19, 2023, 4:06pm UTC](https://discuss.python.org/t/pep-724-stricter-type-guards/34124 "2023-09-19T16:06:06Z")\
**Posts on this page:** 1\
**Showing post:** 32

<div class="post-metadata">

**Author:** ![NeilGirdhar](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/neilgirdhar/32/5776_2.png) [@NeilGirdhar](https://discuss.python.org/u/NeilGirdhar)\
**Post date:** [September 21, 2023, 5:11pm UTC](https://discuss.python.org/t/pep-724-stricter-type-guards/34124/32 "2023-09-21T17:11:06Z")

</div>

> [@pf\_moore](#):
>
> All I can say to this is that I consider it a pretty terrible situation,

You’re probably right that the situation can be significantly improved. But I think we have to recognize the benefits of the situation as well: The typing people have built a masterpiece in a few short years. And they’ve done that in part because they are free to innovate without PEPs and free to change their minds without years of deprecation periods.

Consider an issue like [this](https://github.com/python/typing/issues/1376): PEP 698 was updated after a five minute discussion rather than a whole other PEP. I agree with you wholeheartedly that the result of the discussion should be documented with `typing.overload`.

> [@pf\_moore](#):
>
> It’s already been pointed out that this breaks real-world existing code

The code works exactly as it used to, but the type checking may produce different errors. That’s a much less significant problem, and I think it’s unfair to characterize it as “breaking”.

If a project wants to rely on type errors not changing, they can pin their type checker version. Most users don’t pin and are instead _thrilled_ when type errors change. Usually they disappear, and so the only thing you need to do is remove ignore directives. Sometimes, they reveal problems you didn’t know about, which means adding ignore directives or refactoring. The code seems better after these changes. I encourage you to actually use type checking for a while to get a feel for this experience.

> [@pf\_moore](#):
>
> But I think that with wider community participation - partly due to discussions now being on Discourse, and partly just increased popularity - I think there will be a demand for tighter control.

Funnily enough, there appeared a proposal for a new [typing governance process](https://discuss.python.org/t/proposed-new-typing-governance-process/34244). However, I personally think that the control should be unlike the PEP process, and not have the backwards compatibility guarantees and deprecation periods that are being suggested—at least not for most changes and at least not yet. In my opinion, (we) typing users benefit _more_ from typing being flexible enough to change without such a heavy guarantees than we would gain from “tight control” and “strict guarantees”.

> [@pf\_moore](#):
>
> To be clear, I’m only talking about changes to behaviour _documented in a PEP or the stdlib docs_.

This a very good point. Maybe typing PEPs will be replaced by a different process (as per the new governance process). And although typing is documented in the standard library documentation, there may be a way to allow typing to keep changing quickly—either by editing old docs, or by documenting typing somewhere else.

> [@effigies](#):
>
> . I think we can have both and teach both, and that the reasons for rejecting `StrictTypeGuard` do not ring true for me as a non-expert.

We don’t even have one good example yet of a non-strict type guard, so why would you want to “have both”? In the long run, it seems that we only want the strict type guard?

> [@sirosen](#):
>
> Plus, they’re the only thing which a library author can control – I can’t determine which type checker or what settings will be used by my users.

Library users don’t see the type guards that are used in library code. They only see the interface. This change to type guards would not change the meaning of library interfaces.

---

_[View the full topic](https://discuss.python.org/t/pep-724-stricter-type-guards/34124)._
