How to find type hints for psycopg2 functions
Question:
How can one find what type hints to use when annotating my python code for to package functions eg. What will thepsycopg2.connect
return so that I can put it in place of ???
eg:
def sql_connect(sql_config: dict = None) -> ???:
db = psycopg2.connect(
host=sql_config["host"],
port=sql_config["port"],
dbname=sql_config["database"]
)
return db
Answers:
Just use the psycopg2.connection
as the type hint.
Also check with type(sql_connect())
How can one find what type hints to use when annotating my python code for to package functions eg. What will thepsycopg2.connect
return so that I can put it in place of ???
eg:
def sql_connect(sql_config: dict = None) -> ???:
db = psycopg2.connect(
host=sql_config["host"],
port=sql_config["port"],
dbname=sql_config["database"]
)
return db
Just use the psycopg2.connection
as the type hint.
Also check with type(sql_connect())