| ▲ | Show HN: Gawain – Require type hints on all Python variables(github.com) |
| 47 points by MarinhoD 5 hours ago | 22 comments |
| Yes, i really hate "dict[str, ANY]" |
|
| ▲ | gavmor 4 hours ago | parent | next [-] |
| 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. |
| |
| ▲ | bustermellotron 3 hours ago | parent [-] | | > "You have readily recapitulated, by fully accurate accounting, all covenants that I declared." This should be in the README. |
|
|
| ▲ | santiagobasulto an hour ago | parent | prev | next [-] |
| 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. |
| |
| ▲ | IceDane an hour ago | parent [-] | | Can you elaborate how those languages have "done typing very wrong"? |
|
|
| ▲ | michalc 2 hours ago | parent | prev | next [-] |
| 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... |
| |
|
| ▲ | orsorna 4 hours ago | parent | prev | next [-] |
| 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. |
| |
|
| ▲ | Garlef 4 hours ago | parent | prev | next [-] |
| 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) |
| |
| ▲ | skeledrew 3 hours ago | parent [-] | | > The python syntax is not pretty to begin That's an interesting objection, given Python is the closest programming language to English. Understandable if your native language isn't English, but really strange otherwise IMO. | | |
| ▲ | stackghost 2 hours ago | parent | next [-] | | Semantic indentation is fundamentally an insane design. And I don't mean "insane" as a colloquialism for "dumb". I mean it is literally not a sane choice to make. English would make a horrid programming language, so being close to it is not a plus. | | |
| ▲ | UltraSane 6 minutes ago | parent | next [-] | | Considering the endless arguments over C syntax I really don't see what is so weird about Python indentation. It has the nice effect of making code look a lot more consistent. | |
| ▲ | teiferer an hour ago | parent | prev [-] | | In the age of auto-formatters, I have less and less sympathy for this point of view. Any widely used formatter indents along semantics anyway, so why clutter your code with curly braces everywhere if stucture is clear from indentation? Might as well make it semantic. Before auto-formatters, there was the occasional case where you could argue that some quick hack made something more readable, at the expense of less consistency and wasted time arguing about this in code reviews. But that ship has sailed, arguably rightfully so. And that doesn't even bring the LLM angle. If code is generated by a machine anyway and you just review it, if even that, why still bash indentation as a semantic construct? | | |
| ▲ | stackghost an hour ago | parent [-] | | If you have to run your source code through a formatter to make sure it doesn’t have mixed tabs and spaces that is not the flex you seem to think it is. If you’re going to just have an LLM write all the code anyway why bother with a slow janky mess like python at all? Just make it write rust or java or go or literally anything. Imagine having a magical machine that can write code in any programming language ever conceived, and you ask it to pick the language whose community thinks virtualenvs are a reasonable solution as opposed to a mark of profound shame. Couldn’t be me. |
|
| |
| ▲ | lefra 28 minutes ago | parent | prev [-] | | Python code using advanced features of the language (see for example [1]) look as much like line noise as C++ template metaprogramming. If "close to the english language" is your criterion, I believe COBOL should rank higher than python: ADD transaction-balance TO total-balance. Is readable to a layman whereas this isn’t: total-balance += transaction-balance Or even worse for someone who learned algebra but not programming (this looks like an equation, and transaction-balance is therefore equal to zero): total-balance = total-balance + transaction-balance [1] https://stackoverflow.com/questions/6760685/what-is-the-best... |
|
|
|
| ▲ | __mharrison__ 4 hours ago | parent | prev | next [-] |
| Be cool to have a strict Python that actually runs fast with types... |
| |
|
| ▲ | isaachinman 3 hours ago | parent | prev | next [-] |
| Maybe just... Stop writing py? |
|
| ▲ | rbnafo 2 hours ago | parent | prev | next [-] |
| Python 9.x release notes: we are a statically typed language now. |
|
| ▲ | cadamsdotcom 3 hours ago | parent | prev [-] |
| 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. |