logoalt Hacker News

Show HN: Gawain – Require type hints on all Python variables

42 points • by MarinhoD • today at 4:39 AM • 20 comments • view on HN

Yes, i really hate "dict[str, ANY]"


Comments

santiagobasulto • today at 7:57 AM

This is awful. I love type correctness, but going all the way to flag PORT=8080? There should be a basic level of type inference.

Especially for “typed” languages that have done typing very wrong, as Python or Typescript.

gavmor • today at 5:44 AM

Gawain, the finest night alive (literally Þe most kydde knyȝtez vnder Krystes seluen) committed one indisputable, albeit minor, transgression under a regime of unsparing precision.

> ȝe han redily rehersed, bi resoun ful trwe, Alle þe covenauntz þat I yow kende...

("You have readily recapitulated, by fully accurate accounting, all covenants that I declared.")

I can't think of a more fitting name except, perhaps, the speaker of these lines: the exacting Lord Bertilak.

➕ show 1 reply
michalc • today at 7:28 AM

I think similar to `dict[str, Any]`, my (justified?) recent pet peeve is `| None`.

I posted this yesterday pretty much on that: https://charemza.name/blog/posts/software/type-safety/type-s...

➕ show 1 reply
orsorna • today at 5:54 AM

This is cool. And I appreciate the cheeky comment about not using this program if your IDE or whatever does type checking already :)

But honestly, after I realized I appreciate types being enforced, I started writing in different languages. I rarely return to Python unless I'm scripting something that doesn't require longevity.

➕ show 1 reply
Garlef • today at 5:36 AM

Maybe not for me but I love the attitude.

(And actually, my personal objection is incidental: The python syntax is not pretty to begin with and the situation does not improve with even more visual verbosity)

➕ show 1 reply
__mharrison__ • today at 5:22 AM

Be cool to have a strict Python that actually runs fast with types...

➕ show 2 replies
isaachinman • today at 6:21 AM

Maybe just... Stop writing py?

rbnafo • today at 6:59 AM

Python 9.x release notes: we are a statically typed language now.

cadamsdotcom • today at 6:35 AM

Yes! Exactly what a long term codebase needs.

May as well be strict, right! We have the technology.

Agents will fix lint issues same as any other kind of error. So lint in a blocking pre-commit hook. End result: 100% strongly typed agent written code, at least one kind of slop gone.

blunt_read • today at 4:59 AM

[flagged]

mesm7903 • today at 6:36 AM

[flagged]

jheriko • today at 5:52 AM

[dead]