this post was submitted on 23 Apr 2024
81 points (100.0% liked)

Python

6250 readers
83 users here now

Welcome to the Python community on the programming.dev Lemmy instance!

๐Ÿ“… Events

October 2023

November 2023

PastJuly 2023

August 2023

September 2023

๐Ÿ Python project:
๐Ÿ’“ Python Community:
โœจ Python Ecosystem:
๐ŸŒŒ Fediverse
Communities
Projects
Feeds

founded 1 year ago
MODERATORS
 

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

you are viewing a single comment's thread
view the rest of the comments
[โ€“] phdepressed@sh.itjust.works 2 points 5 months ago (1 children)
[โ€“] FizzyOrange@programming.dev 4 points 5 months ago

Python lets you add static type annotations to your program, so you can say "this variable should be and int or a string", and that means Pyright (a fantastic static type checker) can tell you if you screw up and forget that it might be a string.