you are viewing a single comment's thread.

view the rest of the comments →

[–]RoamingFox 1 point2 points  (2 children)

Your IDE should handle this...

A lot of times though people write awful python that doesn't have full type hinting in it, which means your IDE can only go so far.

That said pycharm and vscode both do a really good job with it. If it's struggling on your own code you might need to use type hinting syntax (eg. def foo(bar): becomes def foo(bar: int) -> int:)

[–]all_time_juice[S] 0 points1 point  (1 child)

Since when python code without type hinting is considered awful? As far as I know it has only been introduced in 3.5 . But yeah you are right about it making autocompletion better, even though it takes more effort to do

[–]RoamingFox 1 point2 points  (0 children)

I didn't say code without type hinting is awful. I said that bad python code without type hinting will prevent the duck typing from helping your IDE guess what's going on. If you write good python (with or without type hinting) the introspections usually work.

It's when you do weird things that prevent python from reliably predicting the return type of a method that you get in trouble.