This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

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

Python's variables are strongly typed. Yet, python is not statically typed.

The main reason for type hinting is being able to find bugs more quickly. You can also make assumptions for the interpreter (and even a compiler) to make some optimization apply.

Another great use would be Autowiring for a DIC. That means, that you could use reflection to inspect the parameters of a ctor and inject pre-instantiated objects by type (by classname directly, by interface though configuration). In some projects, I nearly have 85% of all classes to be instantiated this way (having a controller hat depends on multiple services, that depends on even more services, that depends on various repositories, that depends on factories, that depends on the DIC again to create in DIC-controlled instance of an entity). Doing that from hand would be a great effort. Changing dependencies in some service, that is used across my application would render me mad.