If you thought misspelling a variable was bad, then get ready for misreading documentation of OS API, then not realize why your implementation doesn’t work for a quite a long time.
Programming has its highs and lows. Yesterday I spent four hours trying to write a script that honestly probably won’t even be useful to anyone.
Today I felt like a god because I built a recursive query to pull some ridiculously obscure data from our database.
Tomorrow I’ll probably delete a table in prod or something.
You win some, you lose some!
What compiler are you using that wouldn’t tell you right away?
This literally happened to me yesterday, but with filenames. I was failing to configure a program until an hour later I found out that I mispelled the config file as
colors.ini
instead ofcolor.ini
.I like that even here on Lemmy, with inline code format,
colors.ini
is not being colored butcolor.ini
is. Great symbolism for your issue.
…for people who refuse to use static types.
Static types are great, but not exactly what would have helped here, any decent language or at least a linter should catch the use of a not declared identifier.
def foo(x): return x.whatevr
No linter is going to catch that.
class MyClass: def __init__(self, x: int): self.whatever: int = x def foo(x: MyClass) -> int: return x.whatevr
Any decent IDE would give you an error for unresolved attribute. Likewise it would warn you of type error if the type of
x.whatever
didn’t match the return type offoo()
Yes because you used static type annotations. This thread was about code that doesn’t use static types (or static type annotations/hints).
Nope, don’t need to. WebStorm can even detect nonexistent attributes for objects whose format the back-end decides, and tbh I’m not sure what sort of sorcery it uses.
Yeah IntelliJ does amazingly without type annotations but even it can’t do everything. E.g. if you’re using libraries without type annotations, or if you don’t call functions with every possible type (is your testing that good? No.)
Static types have other benefits anyway so you should use them even if everyone in your team uses IntelliJ.
Yeah, our company has been meaning to transition to them for a while. I started saying Jsdoc comments but people complained about the pollution. Then I said fine, we’ll do TypeScript one day instead.
That one day has yet to come. I don’t actually get to decide much at this company, after all. Aah, technical debt.
You’re both right. It’s possible to write code that gets linted well in Python, yes, but you’re often not working with just your code. If a library doesn’t use typing properly, not a lot to be done without a ton more effort.
It’s python, just use type hinting already and your linter will catch that.
Also some winters can look at the use of food and see the type being passed in.
Autocorrect got you pretty bad, there.
I was very confused, why we’re suddenly talking about rationing food during winter. 🙃
Holy crap that’s wild, new phones autocorrect is out to get me
Yes you can use static type hinting and the static type checker (Mypy or Pyright) will catch that. Linters (Pylint) won’t.
I appreciate the “carrot with a bit out of it” icon.
I spent such a long time the other day trying to figure out why I couldn’t access an application I wrote and served on a home server from my reverse proxy. Next day I take a look at the DNS record I setup again, CNAMEd to the host server instead of the reverse proxy server. Felt dumb.
Use spell check in your code editor and never experience this again.
Spellcheck? My editor proposes known words after 3 characters.
Hey, that’s me! Minus the last panel :)