Twitter user @DanyX23:

TIL: pyright, the python type checking engine that is used by VS Code, has support for exhaustiveness checking for match statements with union types!

If you add the following to your pyproject.toml, you’ll get the attached warning

[tool.pyright] reportMatchNotExhaustive = true

  • GBU_28@lemm.ee
    link
    fedilink
    English
    arrow-up
    3
    arrow-down
    1
    ·
    7 months ago

    There are various ways to monitor and handle types, they just aren’t set up right out of the box. It’s not uncommon for a language to be greatly enhanced by libraries/extensions. Having a robust development environment and standards are just part of writing good code.

    This is not an apology for python not having it all out of the box, I think it should. Some things.just take setup and for now thats how it is.