It is mainly used for documentation only. When someone checks the method signature, they will see that param marked as int , which will tell them that the author of the method expected them to pass an int .
Since Python programmers use duck printing, this does not mean that you need to pass int , but it tells you that the code expects something "int-like". Therefore, you probably have to transmit something fundamentally "numerical" in nature, which supports arithmetic operations. Depending on the method, it may be used as an index, or it may not be.
However, since this is syntax, not just a comment, the annotation is visible to any code that wants to view it. This opens up the possibility of writing a typecheck decorator that can provide strict type checking for arbitrary functions; this allows you to put the type checking logic in one place, and each method will declare which parameters it wants, strictly type checking (adding type annotation) with minimal syntax, in a way that is visible to client programmers who look at method definitions to find out interface.
Or you can do other things with these annotations. A standardized value has not yet been developed. Maybe if someone comes up with a killer function that uses them and has a huge adoption, then it will become part of the Python language, but I suspect that the flexibility to use them as you want will be too useful for that.
source share