I know about builtin types. But how I can specify rare objects, a db connection object for example?
def get_connection_and_cursor() -> tuple[psycopg2.extensions.cursor, psycopg2.extensions.connection]:
connection = psycopg2.connect(dbname=db_name, user=db_user, password=db_password, host='127.0.0.1', port="5432")
# connection.autocommit = True
cursor = connection.cursor()
return connection, cursor
Checking the type, here is the output of:
type(cursor):psycopg2.extensions.cursorandtype(connection):psycopg2.extensions.connection.
What should I do with it?