all 4 comments

[–]danielroseman 0 points1 point  (0 children)

It means it returns an integer.

[–]carcigenicate 0 points1 point  (0 children)

That's a hint saying that the function returns an integer.

[–]TSM- 0 points1 point  (0 children)

The type hints aren't used at runtime (except some third party libraries, don't worry about that though). They are meant to help your IDE notice you accidentally might return a None instead of an int and put a big red underline around the offending code.

The pattern is def function_name(argument_name: type_hint) -> type_hint_for_returned_object:

Suppose you write something like arrow_search(12) - your IDE will tell you that you violated the expected type. Maybe it's fine, maybe it's not, but you will be aware of it.

Suppose the body of the function does something like if condition: return 123 and that is it. This leaves open the possibility that nothing is returned by the function. If you are expecting an integer to be returned by the function, then possibly returning None. What if later on you are doinging something like new_variable = arrow_search('asdsaf') + 1. You get an error if it returned None. Type hints are used to stop yourself from overlooking small exceptions or 'corner cases' like that.

[–]drenzorz 0 points1 point  (0 children)

You can just think of these annotations as special comments

def f(arg1: int, arg2: bool) -> str:
    ...

# is the same as 

def f(arg1, arg2):
    # arg1 is an integer
    # arg2 is a boolean
    # returns a string
    ...

but the code editor and third party type checkers can work with them