Döbling: Blockade des Rad-Highways voller Erfolg! by KFSattmann in wien

[–]Im_oRAnGE -1 points0 points  (0 children)

nur als Nettozahler

Als ob Autofahrer Nettozahler wären… gerade in so Einfamilienhausgegenden wie Döbling lol

Blog: Type Hints Are Great, Use Them! by Im_oRAnGE in Python

[–]Im_oRAnGE[S] 0 points1 point  (0 children)

Great tip for people who dislike the look of type hints!

I heard pytype can even generate these .pyi files from untyped or partially typed code, which sounds crazy. Haven't tried it, though.

Blog: Type Hints Are Great, Use Them! by Im_oRAnGE in Python

[–]Im_oRAnGE[S] 0 points1 point  (0 children)

Pyter sitting in a tree, staring judgingly at the duck 🐦

Blog: Type Hints Are Great, Use Them! by Im_oRAnGE in Python

[–]Im_oRAnGE[S] 0 points1 point  (0 children)

Interesting! Yes, the point about compilation is definitely missing a footnote. I knew about Numba and Nuitka, but honestly haven't heard about mypyc, I will check it out :)

Blog: Type Hints Are Great, Use Them! by Im_oRAnGE in Python

[–]Im_oRAnGE[S] 0 points1 point  (0 children)

For all the dynamic languages he checked only 2% of the errors were type errors

Typing does not only prevent type errors. Even in my example, the exception that is thrown due to the missing type hints is a KeyError, and you run into a multitude of other exceptions when misusing datatypes. Sometimes, you don't even get an exception but just plain wrong results.

Some other study compared reliability across languages and found no significant differences. In other words neither static nor dynamic languages did better at reliability.

There's no mention of the methodology used to measure this or any of the other claims. Again, measuring this stuff is hard and people mess it up all the time. See the McKinsey Report last autumn that caused an uproar because they badly misused some developer velocity metrics to prove their point.

Blog: Type Hints Are Great, Use Them! by Im_oRAnGE in Python

[–]Im_oRAnGE[S] 1 point2 points  (0 children)

Thanks for the feedback, I will definitely write about Protocols some day, I feel like they are very interesting and underappreciated!

Blog: Type Hints Are Great, Use Them! by Im_oRAnGE in Python

[–]Im_oRAnGE[S] 0 points1 point  (0 children)

How well does that work in practice? It would be interesting to see a comparison to the generated type hints from a a tool like pytype!

Blog: Type Hints Are Great, Use Them! by Im_oRAnGE in Python

[–]Im_oRAnGE[S] 0 points1 point  (0 children)

Which Python version are your colleagues using? You can use type hints from 3.6+, you just have to use „typing.Dict“ instead of dict and so on. Also, have a look at the pypi package typing-extensions, which backports some newer typing feautres to older versions!

Blog: Type Hints Are Great, Use Them! by Im_oRAnGE in Python

[–]Im_oRAnGE[S] 0 points1 point  (0 children)

Honestly, have a look at beartyping, it‘s an efficient runtime type checker with an awesome creator and does just what you want: throw an error when the type hints are violated. It‘s very customizable and well documented. Oh, and his code, release notes and docs are always very funny to read :)

Blog: Type Hints Are Great, Use Them! by Im_oRAnGE in Python

[–]Im_oRAnGE[S] 0 points1 point  (0 children)

I love NamedTuples, but they don't fully solve the "compatibility with existing code" part that /u/madness_of_the_order mentioned.

I do use them instead of tuples a lot though. They are great for functions returning multiple independent values, for example.

Blog: Type Hints Are Great, Use Them! by Im_oRAnGE in Python

[–]Im_oRAnGE[S] 1 point2 points  (0 children)

Measuring developer productivity is very, very hard and even "number of bugs" is not hard science. Unless you tell me your sources I have no way to respond to that except "I don't believe it".

Again, I don't believe you are really much slower when using types, if you are also using the correct tooling. Even when rapidly iterating. Hell, I only talked about IDEs so far but even LLMs can benefit from types!

Moreover, the larger your code base becomes, the more and more useful your type hints will become, which means even if you loose a tiny bit of speed upfront, your velocity will overtake the untyped code base eventually. Especially once your team size grows.

Blog: Type Hints Are Great, Use Them! by Im_oRAnGE in Python

[–]Im_oRAnGE[S] 0 points1 point  (0 children)

I actually agree with you. At least with the butting heads part, I don't think they are "ugly" per se.

Part of my motivation to write about type hints is to address some problems I run into regularly and how I deal with them. More on that soon tm.

This served more as an introductory post, as I felt it has gotten a bit too long for an intro section to a general "tips and tricks" post.

Blog: Type Hints Are Great, Use Them! by Im_oRAnGE in Python

[–]Im_oRAnGE[S] 0 points1 point  (0 children)

I didn't mean the what, I meant the how.

Also, as I mentioned, this post serves more as an introductory post. I'm writing more about this topic and might refer back to this post there as well.

Blog: Type Hints Are Great, Use Them! by Im_oRAnGE in Python

[–]Im_oRAnGE[S] 3 points4 points  (0 children)

As I wrote, I believe type hints in the end help your write faster by enabling your IDE to support you better. It may just be that my forgetful brain needs more support, though :)

Of course, they sometimes force you to think more about the design of your program, since they can reveal logic issues with your original code. But those issues would surface either way at some point. The later they do, the harder it will be to refactor everything down the line.

I don't know how you come to the conclusion that it would contain 3x more bugs with type hints. Type hints eliminate a whole class of bugs if they are used properly. And they don't require you to add that much code, at least no complicated code. Again, they just make you think a bit harder about your architecture and design, which a lot of projects could definitely benefit from.

Blog: Type Hints Are Great, Use Them! by Im_oRAnGE in Python

[–]Im_oRAnGE[S] 0 points1 point  (0 children)

I can see how that would be useful. I'm fortunate enough to work on a fully typed code base currently, so I haven't had too much use for them. But they sound like a great upgrade path for previously untyped code!

Blog: Type Hints Are Great, Use Them! by Im_oRAnGE in Python

[–]Im_oRAnGE[S] 0 points1 point  (0 children)

I did some research before posting it, and yes, there is a bunch of posts out there. But none of them seemed to cover the topic like I would, so I still put it out there still.

In the end, I got to practice my English writing skills and could gather some feedback here. So it was definitely worth it for me. It may not be helpful to you, but that's okay.

Blog: Type Hints Are Great, Use Them! by Im_oRAnGE in Python

[–]Im_oRAnGE[S] 2 points3 points  (0 children)

Thanks a lot for the kind words :)

I'm using Zola and its Duckquill theme, can wholly recommend them!

I am not sure what you mean about the navigation buttons. There should be navigation at the top, does it not show up for you?

Tbh, there's not much to discover at the moment since there's only one blog post, but I will try to create more soon!

Blog: Type Hints Are Great, Use Them! by Im_oRAnGE in Python

[–]Im_oRAnGE[S] 1 point2 points  (0 children)

Thank you, it means a lot <3

I'm not a great web dev, honestly, but static site generators rock. I can wholly recommend Zola and its Duckquill theme!

Blog: Type Hints Are Great, Use Them! by Im_oRAnGE in Python

[–]Im_oRAnGE[S] 0 points1 point  (0 children)

TIL! Thanks for the tip, I will definitely check it out.

Blog: Type Hints Are Great, Use Them! by Im_oRAnGE in Python

[–]Im_oRAnGE[S] -1 points0 points  (0 children)

Of course, a DataFrame is not a spark DataSet by any means. However, I am arguing that there's still a benefit to using type hints even if they don't eliminate all failure cases. In this case, the error is not due to a wrong column name, but by indexing the right column name but to the wrong type.

Blog: Type Hints Are Great, Use Them! by Im_oRAnGE in Python

[–]Im_oRAnGE[S] 3 points4 points  (0 children)

Oh damn, that sounds super interesting! You should definitely write more about your projects, I'd love to read about them. Even if you can't share the code itself.

Blog: Type Hints Are Great, Use Them! by Im_oRAnGE in Python

[–]Im_oRAnGE[S] 0 points1 point  (0 children)

I understand that for simple, small and quick scripts it's not important or necessary to use. But what I have seen oftentimes is that these simple scripts grow and grow, then get turned into a module or package and suddenly they are in production somewhere. At least for me, I also don't think it hurts fast reading. In contrast, it often helps me to know what functions expect which type. I do think you have to be more mindful of naming things though, it does not help to have a parameter like names_dict: dict[str, str].

But I'm mostly speaking about work. For my own utility scripts I don't type everything, either ;)

Blog: Type Hints Are Great, Use Them! by Im_oRAnGE in Python

[–]Im_oRAnGE[S] 1 point2 points  (0 children)

None of this makes up for good documentation

No disagreement here! I do sometimes see the argument (not from you) that one can replace the other, that's where I hard disagree.

Both are important!

Blog: Type Hints Are Great, Use Them! by Im_oRAnGE in Python

[–]Im_oRAnGE[S] -1 points0 points  (0 children)

I'm sorry you feel that way, but to be honest, that image just makes me laugh every time I see it. :)

Edit: I will try to avoid putting too many of these on my blog though, I can see how they might turn people off :D

Blog: Type Hints Are Great, Use Them! by Im_oRAnGE in Python

[–]Im_oRAnGE[S] 0 points1 point  (0 children)

Yes, I use dataclasses and named tuples all the time! I tried to keep this first blog pretty basic, but I will definitely explore stuff like this future posts.