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

Python

99 readers
2 users here now

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

πŸ“… Events

PastNovember 2023

October 2023

July 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
[–] KindaABigDyl@programming.dev 20 points 7 months ago* (last edited 7 months ago) (2 children)

This is honestly so frustrating to see bc I'll still never understand why Python isn't just statically typed.

It's right there in the Zen:

Explicitness is better than implicitness

It wouldn't even have to be less simple as it could still be weakly typed, a la Rust or Haskell, but not as robust.

You wouldn't need these extra special tools if the language was just built right!

Same goes for the try/catch exception system where runtime errors can pop up bc you don't have to handle exceptions:

Errors should never pass silently.

Unless explicitly silenced.

Python is a good language that could've been a great one smh

[–] GBU_28@lemm.ee 3 points 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.

[–] mao@lemmy.sdf.org 2 points 7 months ago

I feel like Python is coming to its senses in the recent years, with releases focusing on typing constructs and the match statement. I think they're on the path to be a great statically typed language, don't you think?