mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-14 15:57:07 +08:00
* Annotations for psycopg2.ConnectionInfo These annotations come from the documentation here: https://www.psycopg.org/docs/extensions.html#psycopg2.extensions.ConnectionInfo If there was doubt, I referred to the libpq documentation cited by psycopg2's docs. I wasn't completely sure about `dsn_parameters`. Psycopg2's docs list it as an `dict`, and the example suggests it's a `dict[str, str]` at that. From psycopg2's source I found1d3a89a0bb/psycopg/conninfo_type.c (L183-L206)which is implemented here:1d3a89a0bb/psycopg/utils.c (L251-L279)I'm no expert in CPython's API, but this looks to me like it's building a `dict[str, str]`. Additionally, the libpq docs https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PQCONNINFO https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PQCONNDEFAULTS show that the underlying data just consists of strings. Additionally, I'm pretty sure from this chunk of source1d3a89a0bb/psycopg/conninfo_type.c (L581-L598)That `ConnectionInfo.__init__` takes one positional-only argument, which must be a `psycopg2.connection`. But I don't think users are intended to be constructing this type, so I've not added that annotation. * Annotate `connection.info` and related attributes * Make ConnectionInfo attributes properties According to1d3a89a0bb/psycopg/conninfo_type.c (L534-L563)* Mark connection attributes as readonly according to8ef195f2ff/psycopg/connection_type.c (L1244)* Explain why some properties aren't `T | None`