Search notes:

Python: __annotations__

__annotations__ is a dict that provides some annotations about global(?) variables, classes, class attributes, function parameters and return types.
__annotations__ is one of the names that is present in the top level scope (__name__ == '__main__') as returned by dir().

Supplying a function with an annotation about its return type

The special syntax def funcName() -> type adds the key 'return' to the __annotations__ dictionary. The value for this key is the specified type:
def sayHello() -> str:
    return 'hello world'

print('sayHello() is supposed to return a {}'.format(sayHello.__annotations__['return'].__name__))
#
#  sayHello() is supposed to return a str
Github repository about-Python, path: /dunders/__annotations__/def-1.py
It should be noted that the annotated type is not enforced at runtime:
def Func() -> int:
    return 'haha, not an int'

print(Func())
Github repository about-Python, path: /dunders/__annotations__/def-2.py

Supplying annotations about a function parameter

A function parameter is annotated with a colon (:) followed by the annotation.
def F(num: 'A number',
      txt: 'A text'   ='Hello World'):

    print('num:', num)
    print('txt:', txt)
    print('')

F(42)
F(txt = 'good bye', num = 99)

print('Annotations:')
for annot, val in F.__annotations__.items():
    print('{:4s}: {}'.format(annot, val))
Github repository about-Python, path: /dunders/__annotations__/def-param.py

See also

__doc__ and docstrings.
Other dunders

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758199430, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/Python/dunders/__annotations__/index(81): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78