82
submitted 5 months ago by mao@lemmy.sdf.org to c/python@programming.dev

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
[-] 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.

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

Python

6265 readers
64 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