518
you are viewing a single comment's thread
view the rest of the comments
[-] bjornsno@lemm.ee 5 points 6 months ago

I believe raises is the de facto Python version of throws, but no tools seem to exist to actually handle it.

[-] eager_eagle@lemmy.world 2 points 6 months ago

that's still a docstring, idk of linters that take docstrings into account at all. We need a semantic approach for this kind of annotation.

[-] bjornsno@lemm.ee 1 points 6 months ago

That's way harder to ask for. A docstring solution is fine so long as the linters know to pick it up.

[-] eager_eagle@lemmy.world 1 points 6 months ago* (last edited 6 months ago)

I don't think so. A half-measure using docstrings would likely take more processing power and require an ad-hoc implementation because comments are not broken down into ast components afaik. It would also be more costly in the long run if they decide to convert it into a proper syntax, as a result of docstrings not having a single standard way of being written.

Python has introduced several syntactic changes for type annotations, this is not unreasonable.

this post was submitted on 12 May 2024
518 points (97.1% liked)

Programmer Humor

32611 readers
46 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS