diff --git a/pyrightconfig.stricter.json b/pyrightconfig.stricter.json index 8fedbb53c..0f45444e3 100644 --- a/pyrightconfig.stricter.json +++ b/pyrightconfig.stricter.json @@ -47,6 +47,7 @@ "stubs/prettytable", "stubs/protobuf", "stubs/psutil", + "stubs/psycopg2", "stubs/Pygments", "stubs/PyMySQL", "stubs/python-dateutil", diff --git a/stubs/psycopg2/@tests/stubtest_allowlist.txt b/stubs/psycopg2/@tests/stubtest_allowlist.txt new file mode 100644 index 000000000..ea36bb094 --- /dev/null +++ b/stubs/psycopg2/@tests/stubtest_allowlist.txt @@ -0,0 +1,2 @@ +psycopg2.connection +psycopg2.cursor diff --git a/stubs/psycopg2/METADATA.toml b/stubs/psycopg2/METADATA.toml new file mode 100644 index 000000000..d8484dc60 --- /dev/null +++ b/stubs/psycopg2/METADATA.toml @@ -0,0 +1 @@ +version = "2.9" \ No newline at end of file diff --git a/stubs/psycopg2/psycopg2/__init__.pyi b/stubs/psycopg2/psycopg2/__init__.pyi new file mode 100644 index 000000000..d1165cd2d --- /dev/null +++ b/stubs/psycopg2/psycopg2/__init__.pyi @@ -0,0 +1,37 @@ +from typing import Any + +# connection and cursor not available at runtime +from psycopg2._psycopg import ( + BINARY as BINARY, + DATETIME as DATETIME, + NUMBER as NUMBER, + ROWID as ROWID, + STRING as STRING, + Binary as Binary, + DatabaseError as DatabaseError, + DataError as DataError, + Date as Date, + DateFromTicks as DateFromTicks, + Error as Error, + IntegrityError as IntegrityError, + InterfaceError as InterfaceError, + InternalError as InternalError, + NotSupportedError as NotSupportedError, + OperationalError as OperationalError, + ProgrammingError as ProgrammingError, + Time as Time, + TimeFromTicks as TimeFromTicks, + Timestamp as Timestamp, + TimestampFromTicks as TimestampFromTicks, + Warning as Warning, + __libpq_version__ as __libpq_version__, + apilevel as apilevel, + connection as connection, + cursor as cursor, + paramstyle as paramstyle, + threadsafety as threadsafety, +) + +def connect( + dsn: Any | None = ..., connection_factory: Any | None = ..., cursor_factory: Any | None = ..., **kwargs +) -> connection: ... diff --git a/stubs/psycopg2/psycopg2/_ipaddress.pyi b/stubs/psycopg2/psycopg2/_ipaddress.pyi new file mode 100644 index 000000000..c3476617f --- /dev/null +++ b/stubs/psycopg2/psycopg2/_ipaddress.pyi @@ -0,0 +1,8 @@ +from typing import Any + +ipaddress: Any + +def register_ipaddress(conn_or_curs: Any | None = ...) -> None: ... +def cast_interface(s, cur: Any | None = ...): ... +def cast_network(s, cur: Any | None = ...): ... +def adapt_ipaddress(obj): ... diff --git a/stubs/psycopg2/psycopg2/_json.pyi b/stubs/psycopg2/psycopg2/_json.pyi new file mode 100644 index 000000000..e7e8619c6 --- /dev/null +++ b/stubs/psycopg2/psycopg2/_json.pyi @@ -0,0 +1,25 @@ +from typing import Any + +JSON_OID: int +JSONARRAY_OID: int +JSONB_OID: int +JSONBARRAY_OID: int + +class Json: + adapted: Any + def __init__(self, adapted, dumps: Any | None = ...) -> None: ... + def __conform__(self, proto): ... + def dumps(self, obj): ... + def prepare(self, conn) -> None: ... + def getquoted(self): ... + +def register_json( + conn_or_curs: Any | None = ..., + globally: bool = ..., + loads: Any | None = ..., + oid: Any | None = ..., + array_oid: Any | None = ..., + name: str = ..., +): ... +def register_default_json(conn_or_curs: Any | None = ..., globally: bool = ..., loads: Any | None = ...): ... +def register_default_jsonb(conn_or_curs: Any | None = ..., globally: bool = ..., loads: Any | None = ...): ... diff --git a/stubs/psycopg2/psycopg2/_psycopg.pyi b/stubs/psycopg2/psycopg2/_psycopg.pyi new file mode 100644 index 000000000..79c74d472 --- /dev/null +++ b/stubs/psycopg2/psycopg2/_psycopg.pyi @@ -0,0 +1,409 @@ +from typing import Any, Tuple, overload + +import psycopg2 +import psycopg2.extensions + +BINARY: Any +BINARYARRAY: Any +BOOLEAN: Any +BOOLEANARRAY: Any +BYTES: Any +BYTESARRAY: Any +CIDRARRAY: Any +DATE: Any +DATEARRAY: Any +DATETIME: Any +DATETIMEARRAY: Any +DATETIMETZ: Any +DATETIMETZARRAY: Any +DECIMAL: Any +DECIMALARRAY: Any +FLOAT: Any +FLOATARRAY: Any +INETARRAY: Any +INTEGER: Any +INTEGERARRAY: Any +INTERVAL: Any +INTERVALARRAY: Any +LONGINTEGER: Any +LONGINTEGERARRAY: Any +MACADDRARRAY: Any +NUMBER: Any +PYDATE: Any +PYDATEARRAY: Any +PYDATETIME: Any +PYDATETIMEARRAY: Any +PYDATETIMETZ: Any +PYDATETIMETZARRAY: Any +PYINTERVAL: Any +PYINTERVALARRAY: Any +PYTIME: Any +PYTIMEARRAY: Any +REPLICATION_LOGICAL: int +REPLICATION_PHYSICAL: int +ROWID: Any +ROWIDARRAY: Any +STRING: Any +STRINGARRAY: Any +TIME: Any +TIMEARRAY: Any +UNICODE: Any +UNICODEARRAY: Any +UNKNOWN: Any +adapters: dict[Any, Any] +apilevel: str +binary_types: dict[Any, Any] +encodings: dict[Any, Any] +paramstyle: str +sqlstate_errors: dict[Any, Any] +string_types: dict[Any, Any] +threadsafety: int + +__libpq_version__: int + +class AsIs: + adapted: Any + def __init__(self, *args, **kwargs) -> None: ... + def getquoted(self, *args, **kwargs): ... + def __conform__(self, *args, **kwargs): ... + +class Binary: + adapted: Any + buffer: Any + def __init__(self, *args, **kwargs) -> None: ... + def getquoted(self, *args, **kwargs): ... + def prepare(self, conn): ... + def __conform__(self, *args, **kwargs): ... + +class Boolean: + adapted: Any + def __init__(self, *args, **kwargs) -> None: ... + def getquoted(self, *args, **kwargs): ... + def __conform__(self, *args, **kwargs): ... + +class Column: + display_size: Any + internal_size: Any + name: Any + null_ok: Any + precision: Any + scale: Any + table_column: Any + table_oid: Any + type_code: Any + def __init__(self, *args, **kwargs) -> None: ... + def __eq__(self, other): ... + def __ge__(self, other): ... + def __getitem__(self, index): ... + def __getstate__(self): ... + def __gt__(self, other): ... + def __le__(self, other): ... + def __len__(self): ... + def __lt__(self, other): ... + def __ne__(self, other): ... + def __setstate__(self, state): ... + +class ConnectionInfo: + backend_pid: Any + dbname: Any + dsn_parameters: Any + error_message: Any + host: Any + needs_password: Any + options: Any + password: Any + port: Any + protocol_version: Any + server_version: Any + socket: Any + ssl_attribute_names: Any + ssl_in_use: Any + status: Any + transaction_status: Any + used_password: Any + user: Any + def __init__(self, *args, **kwargs) -> None: ... + def parameter_status(self, *args, **kwargs): ... + def ssl_attribute(self, *args, **kwargs): ... + +class DataError(psycopg2.DatabaseError): ... +class DatabaseError(psycopg2.Error): ... + +class Decimal: + adapted: Any + def __init__(self, *args, **kwargs) -> None: ... + def getquoted(self, *args, **kwargs): ... + def __conform__(self, *args, **kwargs): ... + +class Diagnostics: + column_name: Any + constraint_name: Any + context: Any + datatype_name: Any + internal_position: Any + internal_query: Any + message_detail: Any + message_hint: Any + message_primary: Any + schema_name: Any + severity: Any + severity_nonlocalized: Any + source_file: Any + source_function: Any + source_line: Any + sqlstate: Any + statement_position: Any + table_name: Any + def __init__(self, *args, **kwargs) -> None: ... + +class Error(Exception): + cursor: Any + diag: Any + pgcode: Any + pgerror: Any + def __init__(self, *args, **kwargs) -> None: ... + def __reduce__(self): ... + def __setstate__(self, state): ... + +class Float: + adapted: Any + def __init__(self, *args, **kwargs) -> None: ... + def getquoted(self, *args, **kwargs): ... + def __conform__(self, *args, **kwargs): ... + +class ISQLQuote: + _wrapped: Any + def __init__(self, *args, **kwargs) -> None: ... + def getbinary(self, *args, **kwargs): ... + def getbuffer(self, *args, **kwargs): ... + def getquoted(self, *args, **kwargs): ... + +class Int: + adapted: Any + def __init__(self, *args, **kwargs) -> None: ... + def getquoted(self, *args, **kwargs): ... + def __conform__(self, *args, **kwargs): ... + +class IntegrityError(psycopg2.DatabaseError): ... +class InterfaceError(psycopg2.Error): ... +class InternalError(psycopg2.DatabaseError): ... + +class List: + adapted: Any + def __init__(self, *args, **kwargs) -> None: ... + def getquoted(self, *args, **kwargs): ... + def prepare(self, *args, **kwargs): ... + def __conform__(self, *args, **kwargs): ... + +class NotSupportedError(psycopg2.DatabaseError): ... + +class Notify: + channel: Any + payload: Any + pid: Any + def __init__(self, *args, **kwargs) -> None: ... + def __eq__(self, other): ... + def __ge__(self, other): ... + def __getitem__(self, index): ... + def __gt__(self, other): ... + def __hash__(self): ... + def __le__(self, other): ... + def __len__(self): ... + def __lt__(self, other): ... + def __ne__(self, other): ... + +class OperationalError(psycopg2.DatabaseError): ... +class ProgrammingError(psycopg2.DatabaseError): ... +class QueryCanceledError(psycopg2.OperationalError): ... + +class QuotedString: + adapted: Any + buffer: Any + encoding: Any + def __init__(self, *args, **kwargs) -> None: ... + def getquoted(self, *args, **kwargs): ... + def prepare(self, *args, **kwargs): ... + def __conform__(self, *args, **kwargs): ... + +class ReplicationConnection(psycopg2.extensions.connection): + autocommit: Any + isolation_level: Any + replication_type: Any + reset: Any + set_isolation_level: Any + set_session: Any + def __init__(self, *args, **kwargs) -> None: ... + +class ReplicationCursor(psycopg2.extensions.cursor): + feedback_timestamp: Any + io_timestamp: Any + wal_end: Any + def __init__(self, *args, **kwargs) -> None: ... + def consume_stream(self, consumer, keepalive_interval=...): ... + def read_message(self, *args, **kwargs): ... + def send_feedback(self, write_lsn=..., flush_lsn=..., apply_lsn=..., reply=..., force=...): ... + def start_replication_expert(self, command, decode=..., status_interval=...): ... + +class ReplicationMessage: + cursor: Any + data_size: Any + data_start: Any + payload: Any + send_time: Any + wal_end: Any + def __init__(self, *args, **kwargs) -> None: ... + +class TransactionRollbackError(psycopg2.OperationalError): ... +class Warning(Exception): ... + +class Xid: + bqual: Any + database: Any + format_id: Any + gtrid: Any + owner: Any + prepared: Any + def __init__(self, *args, **kwargs) -> None: ... + def from_string(self, *args, **kwargs): ... + def __getitem__(self, index): ... + def __len__(self): ... + +_cursor = cursor + +class connection: + DataError: Any + DatabaseError: Any + Error: Any + IntegrityError: Any + InterfaceError: Any + InternalError: Any + NotSupportedError: Any + OperationalError: Any + ProgrammingError: Any + Warning: Any + async_: Any + autocommit: Any + binary_types: Any + closed: Any + cursor_factory: Any + deferrable: Any + dsn: Any + encoding: Any + info: Any + isolation_level: Any + notices: Any + notifies: Any + pgconn_ptr: Any + protocol_version: Any + readonly: Any + server_version: Any + status: Any + string_types: Any + def __init__(self, *args, **kwargs) -> None: ... + def cancel(self, *args, **kwargs): ... + def close(self, *args, **kwargs): ... + def commit(self, *args, **kwargs): ... + @overload + def cursor(self) -> _cursor: ... + @overload + def cursor(self, name=..., cursor_factory: Any = ..., withhold=...) -> Any: ... + def fileno(self, *args, **kwargs): ... + def get_backend_pid(self, *args, **kwargs): ... + def get_dsn_parameters(self, *args, **kwargs): ... + def get_native_connection(self, *args, **kwargs): ... + def get_parameter_status(self, parameter): ... + def get_transaction_status(self): ... + def isexecuting(self, *args, **kwargs): ... + def lobject(self, oid=..., mode=..., new_oid=..., new_file=..., lobject_factory=...): ... + def poll(self, *args, **kwargs): ... + def reset(self): ... + def rollback(self): ... + def set_client_encoding(self, encoding): ... + def set_isolation_level(self, level): ... + def set_session(self, *args, **kwargs): ... + def tpc_begin(self, xid): ... + def tpc_commit(self, *args, **kwargs): ... + def tpc_prepare(self): ... + def tpc_recover(self): ... + def tpc_rollback(self, *args, **kwargs): ... + def xid(self, format_id, gtrid, bqual): ... + def __enter__(self): ... + def __exit__(self, type, value, traceback): ... + +class cursor: + arraysize: int + binary_types: Any + closed: Any + connection: Any + description: Any + itersize: Any + lastrowid: Any + name: Any + pgresult_ptr: Any + query: Any + row_factory: Any + rowcount: int + rownumber: int + scrollable: Any + statusmessage: Any + string_types: Any + typecaster: Any + tzinfo_factory: Any + withhold: Any + def __init__(self, *args, **kwargs) -> None: ... + def callproc(self, procname, parameters=...): ... + def cast(self, oid, s): ... + def close(self): ... + def copy_expert(self, sql, file, size=...): ... + def copy_from(self, file, table, sep=..., null=..., size=..., columns=...): ... + def copy_to(self, file, table, sep=..., null=..., columns=...): ... + def execute(self, query, vars=...): ... + def executemany(self, query, vars_list): ... + def fetchall(self) -> list[Tuple[Any, ...]]: ... + def fetchmany(self, size=...) -> list[Tuple[Any, ...]]: ... + def fetchone(self) -> Tuple[Any, ...] | Any: ... + def mogrify(self, *args, **kwargs): ... + def nextset(self): ... + def scroll(self, value, mode=...): ... + def setinputsizes(self, sizes): ... + def setoutputsize(self, size, column=...): ... + def __enter__(self): ... + def __exit__(self, type, value, traceback): ... + def __iter__(self): ... + def __next__(self): ... + +class lobject: + closed: Any + mode: Any + oid: Any + def __init__(self, *args, **kwargs) -> None: ... + def close(self): ... + def export(self, filename): ... + def read(self, size=...): ... + def seek(self, offset, whence=...): ... + def tell(self): ... + def truncate(self, len=...): ... + def unlink(self): ... + def write(self, str): ... + +def Date(year, month, day): ... +def DateFromPy(*args, **kwargs): ... +def DateFromTicks(ticks): ... +def IntervalFromPy(*args, **kwargs): ... +def Time(hour, minutes, seconds, tzinfo=...): ... +def TimeFromPy(*args, **kwargs): ... +def TimeFromTicks(ticks): ... +def Timestamp(year, month, day, hour, minutes, seconds, tzinfo=...): ... +def TimestampFromPy(*args, **kwargs): ... +def TimestampFromTicks(ticks): ... +def _connect(*args, **kwargs): ... +def adapt(*args, **kwargs): ... +def encrypt_password(*args, **kwargs): ... +def get_wait_callback(*args, **kwargs): ... +def libpq_version(*args, **kwargs): ... +def new_array_type(oids, name, baseobj): ... +def new_type(oids, name, castobj): ... +def parse_dsn(*args, **kwargs): ... +def quote_ident(*args, **kwargs): ... +def register_type(*args, **kwargs): ... +def set_wait_callback(_none): ... diff --git a/stubs/psycopg2/psycopg2/_range.pyi b/stubs/psycopg2/psycopg2/_range.pyi new file mode 100644 index 000000000..fa60fd1bc --- /dev/null +++ b/stubs/psycopg2/psycopg2/_range.pyi @@ -0,0 +1,60 @@ +from typing import Any + +class Range: + def __init__(self, lower: Any | None = ..., upper: Any | None = ..., bounds: str = ..., empty: bool = ...) -> None: ... + @property + def lower(self): ... + @property + def upper(self): ... + @property + def isempty(self): ... + @property + def lower_inf(self): ... + @property + def upper_inf(self): ... + @property + def lower_inc(self): ... + @property + def upper_inc(self): ... + def __contains__(self, x): ... + def __bool__(self): ... + def __nonzero__(self): ... + def __eq__(self, other): ... + def __ne__(self, other): ... + def __hash__(self): ... + def __lt__(self, other): ... + def __le__(self, other): ... + def __gt__(self, other): ... + def __ge__(self, other): ... + +def register_range(pgrange, pyrange, conn_or_curs, globally: bool = ...): ... + +class RangeAdapter: + name: Any + adapted: Any + def __init__(self, adapted) -> None: ... + def __conform__(self, proto): ... + def prepare(self, conn) -> None: ... + def getquoted(self): ... + +class RangeCaster: + subtype_oid: Any + typecaster: Any + array_typecaster: Any + def __init__(self, pgrange, pyrange, oid, subtype_oid, array_oid: Any | None = ...) -> None: ... + def parse(self, s, cur: Any | None = ...): ... + +class NumericRange(Range): ... +class DateRange(Range): ... +class DateTimeRange(Range): ... +class DateTimeTZRange(Range): ... + +class NumberRangeAdapter(RangeAdapter): + def getquoted(self): ... + +int4range_caster: Any +int8range_caster: Any +numrange_caster: Any +daterange_caster: Any +tsrange_caster: Any +tstzrange_caster: Any diff --git a/stubs/psycopg2/psycopg2/errorcodes.pyi b/stubs/psycopg2/psycopg2/errorcodes.pyi new file mode 100644 index 000000000..f4726bd14 --- /dev/null +++ b/stubs/psycopg2/psycopg2/errorcodes.pyi @@ -0,0 +1,304 @@ +def lookup(code, _cache=...): ... + +CLASS_SUCCESSFUL_COMPLETION: str +CLASS_WARNING: str +CLASS_NO_DATA: str +CLASS_SQL_STATEMENT_NOT_YET_COMPLETE: str +CLASS_CONNECTION_EXCEPTION: str +CLASS_TRIGGERED_ACTION_EXCEPTION: str +CLASS_FEATURE_NOT_SUPPORTED: str +CLASS_INVALID_TRANSACTION_INITIATION: str +CLASS_LOCATOR_EXCEPTION: str +CLASS_INVALID_GRANTOR: str +CLASS_INVALID_ROLE_SPECIFICATION: str +CLASS_DIAGNOSTICS_EXCEPTION: str +CLASS_CASE_NOT_FOUND: str +CLASS_CARDINALITY_VIOLATION: str +CLASS_DATA_EXCEPTION: str +CLASS_INTEGRITY_CONSTRAINT_VIOLATION: str +CLASS_INVALID_CURSOR_STATE: str +CLASS_INVALID_TRANSACTION_STATE: str +CLASS_INVALID_SQL_STATEMENT_NAME: str +CLASS_TRIGGERED_DATA_CHANGE_VIOLATION: str +CLASS_INVALID_AUTHORIZATION_SPECIFICATION: str +CLASS_DEPENDENT_PRIVILEGE_DESCRIPTORS_STILL_EXIST: str +CLASS_INVALID_TRANSACTION_TERMINATION: str +CLASS_SQL_ROUTINE_EXCEPTION: str +CLASS_INVALID_CURSOR_NAME: str +CLASS_EXTERNAL_ROUTINE_EXCEPTION: str +CLASS_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION: str +CLASS_SAVEPOINT_EXCEPTION: str +CLASS_INVALID_CATALOG_NAME: str +CLASS_INVALID_SCHEMA_NAME: str +CLASS_TRANSACTION_ROLLBACK: str +CLASS_SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION: str +CLASS_WITH_CHECK_OPTION_VIOLATION: str +CLASS_INSUFFICIENT_RESOURCES: str +CLASS_PROGRAM_LIMIT_EXCEEDED: str +CLASS_OBJECT_NOT_IN_PREREQUISITE_STATE: str +CLASS_OPERATOR_INTERVENTION: str +CLASS_SYSTEM_ERROR: str +CLASS_SNAPSHOT_FAILURE: str +CLASS_CONFIGURATION_FILE_ERROR: str +CLASS_FOREIGN_DATA_WRAPPER_ERROR: str +CLASS_PL_PGSQL_ERROR: str +CLASS_INTERNAL_ERROR: str +SUCCESSFUL_COMPLETION: str +WARNING: str +NULL_VALUE_ELIMINATED_IN_SET_FUNCTION: str +STRING_DATA_RIGHT_TRUNCATION_: str +PRIVILEGE_NOT_REVOKED: str +PRIVILEGE_NOT_GRANTED: str +IMPLICIT_ZERO_BIT_PADDING: str +DYNAMIC_RESULT_SETS_RETURNED: str +DEPRECATED_FEATURE: str +NO_DATA: str +NO_ADDITIONAL_DYNAMIC_RESULT_SETS_RETURNED: str +SQL_STATEMENT_NOT_YET_COMPLETE: str +CONNECTION_EXCEPTION: str +SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION: str +CONNECTION_DOES_NOT_EXIST: str +SQLSERVER_REJECTED_ESTABLISHMENT_OF_SQLCONNECTION: str +CONNECTION_FAILURE: str +TRANSACTION_RESOLUTION_UNKNOWN: str +PROTOCOL_VIOLATION: str +TRIGGERED_ACTION_EXCEPTION: str +FEATURE_NOT_SUPPORTED: str +INVALID_TRANSACTION_INITIATION: str +LOCATOR_EXCEPTION: str +INVALID_LOCATOR_SPECIFICATION: str +INVALID_GRANTOR: str +INVALID_GRANT_OPERATION: str +INVALID_ROLE_SPECIFICATION: str +DIAGNOSTICS_EXCEPTION: str +STACKED_DIAGNOSTICS_ACCESSED_WITHOUT_ACTIVE_HANDLER: str +CASE_NOT_FOUND: str +CARDINALITY_VIOLATION: str +DATA_EXCEPTION: str +STRING_DATA_RIGHT_TRUNCATION: str +NULL_VALUE_NO_INDICATOR_PARAMETER: str +NUMERIC_VALUE_OUT_OF_RANGE: str +NULL_VALUE_NOT_ALLOWED_: str +ERROR_IN_ASSIGNMENT: str +INVALID_DATETIME_FORMAT: str +DATETIME_FIELD_OVERFLOW: str +INVALID_TIME_ZONE_DISPLACEMENT_VALUE: str +ESCAPE_CHARACTER_CONFLICT: str +INVALID_USE_OF_ESCAPE_CHARACTER: str +INVALID_ESCAPE_OCTET: str +ZERO_LENGTH_CHARACTER_STRING: str +MOST_SPECIFIC_TYPE_MISMATCH: str +SEQUENCE_GENERATOR_LIMIT_EXCEEDED: str +NOT_AN_XML_DOCUMENT: str +INVALID_XML_DOCUMENT: str +INVALID_XML_CONTENT: str +INVALID_XML_COMMENT: str +INVALID_XML_PROCESSING_INSTRUCTION: str +INVALID_INDICATOR_PARAMETER_VALUE: str +SUBSTRING_ERROR: str +DIVISION_BY_ZERO: str +INVALID_PRECEDING_OR_FOLLOWING_SIZE: str +INVALID_ARGUMENT_FOR_NTILE_FUNCTION: str +INTERVAL_FIELD_OVERFLOW: str +INVALID_ARGUMENT_FOR_NTH_VALUE_FUNCTION: str +INVALID_CHARACTER_VALUE_FOR_CAST: str +INVALID_ESCAPE_CHARACTER: str +INVALID_REGULAR_EXPRESSION: str +INVALID_ARGUMENT_FOR_LOGARITHM: str +INVALID_ARGUMENT_FOR_POWER_FUNCTION: str +INVALID_ARGUMENT_FOR_WIDTH_BUCKET_FUNCTION: str +INVALID_ROW_COUNT_IN_LIMIT_CLAUSE: str +INVALID_ROW_COUNT_IN_RESULT_OFFSET_CLAUSE: str +INVALID_LIMIT_VALUE: str +CHARACTER_NOT_IN_REPERTOIRE: str +INDICATOR_OVERFLOW: str +INVALID_PARAMETER_VALUE: str +UNTERMINATED_C_STRING: str +INVALID_ESCAPE_SEQUENCE: str +STRING_DATA_LENGTH_MISMATCH: str +TRIM_ERROR: str +ARRAY_SUBSCRIPT_ERROR: str +INVALID_TABLESAMPLE_REPEAT: str +INVALID_TABLESAMPLE_ARGUMENT: str +DUPLICATE_JSON_OBJECT_KEY_VALUE: str +INVALID_ARGUMENT_FOR_SQL_JSON_DATETIME_FUNCTION: str +INVALID_JSON_TEXT: str +INVALID_SQL_JSON_SUBSCRIPT: str +MORE_THAN_ONE_SQL_JSON_ITEM: str +NO_SQL_JSON_ITEM: str +NON_NUMERIC_SQL_JSON_ITEM: str +NON_UNIQUE_KEYS_IN_A_JSON_OBJECT: str +SINGLETON_SQL_JSON_ITEM_REQUIRED: str +SQL_JSON_ARRAY_NOT_FOUND: str +SQL_JSON_MEMBER_NOT_FOUND: str +SQL_JSON_NUMBER_NOT_FOUND: str +SQL_JSON_OBJECT_NOT_FOUND: str +TOO_MANY_JSON_ARRAY_ELEMENTS: str +TOO_MANY_JSON_OBJECT_MEMBERS: str +SQL_JSON_SCALAR_REQUIRED: str +FLOATING_POINT_EXCEPTION: str +INVALID_TEXT_REPRESENTATION: str +INVALID_BINARY_REPRESENTATION: str +BAD_COPY_FILE_FORMAT: str +UNTRANSLATABLE_CHARACTER: str +NONSTANDARD_USE_OF_ESCAPE_CHARACTER: str +INTEGRITY_CONSTRAINT_VIOLATION: str +RESTRICT_VIOLATION: str +NOT_NULL_VIOLATION: str +FOREIGN_KEY_VIOLATION: str +UNIQUE_VIOLATION: str +CHECK_VIOLATION: str +EXCLUSION_VIOLATION: str +INVALID_CURSOR_STATE: str +INVALID_TRANSACTION_STATE: str +ACTIVE_SQL_TRANSACTION: str +BRANCH_TRANSACTION_ALREADY_ACTIVE: str +INAPPROPRIATE_ACCESS_MODE_FOR_BRANCH_TRANSACTION: str +INAPPROPRIATE_ISOLATION_LEVEL_FOR_BRANCH_TRANSACTION: str +NO_ACTIVE_SQL_TRANSACTION_FOR_BRANCH_TRANSACTION: str +READ_ONLY_SQL_TRANSACTION: str +SCHEMA_AND_DATA_STATEMENT_MIXING_NOT_SUPPORTED: str +HELD_CURSOR_REQUIRES_SAME_ISOLATION_LEVEL: str +NO_ACTIVE_SQL_TRANSACTION: str +IN_FAILED_SQL_TRANSACTION: str +IDLE_IN_TRANSACTION_SESSION_TIMEOUT: str +INVALID_SQL_STATEMENT_NAME: str +TRIGGERED_DATA_CHANGE_VIOLATION: str +INVALID_AUTHORIZATION_SPECIFICATION: str +INVALID_PASSWORD: str +DEPENDENT_PRIVILEGE_DESCRIPTORS_STILL_EXIST: str +DEPENDENT_OBJECTS_STILL_EXIST: str +INVALID_TRANSACTION_TERMINATION: str +SQL_ROUTINE_EXCEPTION: str +MODIFYING_SQL_DATA_NOT_PERMITTED_: str +PROHIBITED_SQL_STATEMENT_ATTEMPTED_: str +READING_SQL_DATA_NOT_PERMITTED_: str +FUNCTION_EXECUTED_NO_RETURN_STATEMENT: str +INVALID_CURSOR_NAME: str +EXTERNAL_ROUTINE_EXCEPTION: str +CONTAINING_SQL_NOT_PERMITTED: str +MODIFYING_SQL_DATA_NOT_PERMITTED: str +PROHIBITED_SQL_STATEMENT_ATTEMPTED: str +READING_SQL_DATA_NOT_PERMITTED: str +EXTERNAL_ROUTINE_INVOCATION_EXCEPTION: str +INVALID_SQLSTATE_RETURNED: str +NULL_VALUE_NOT_ALLOWED: str +TRIGGER_PROTOCOL_VIOLATED: str +SRF_PROTOCOL_VIOLATED: str +EVENT_TRIGGER_PROTOCOL_VIOLATED: str +SAVEPOINT_EXCEPTION: str +INVALID_SAVEPOINT_SPECIFICATION: str +INVALID_CATALOG_NAME: str +INVALID_SCHEMA_NAME: str +TRANSACTION_ROLLBACK: str +SERIALIZATION_FAILURE: str +TRANSACTION_INTEGRITY_CONSTRAINT_VIOLATION: str +STATEMENT_COMPLETION_UNKNOWN: str +DEADLOCK_DETECTED: str +SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION: str +INSUFFICIENT_PRIVILEGE: str +SYNTAX_ERROR: str +INVALID_NAME: str +INVALID_COLUMN_DEFINITION: str +NAME_TOO_LONG: str +DUPLICATE_COLUMN: str +AMBIGUOUS_COLUMN: str +UNDEFINED_COLUMN: str +UNDEFINED_OBJECT: str +DUPLICATE_OBJECT: str +DUPLICATE_ALIAS: str +DUPLICATE_FUNCTION: str +AMBIGUOUS_FUNCTION: str +GROUPING_ERROR: str +DATATYPE_MISMATCH: str +WRONG_OBJECT_TYPE: str +INVALID_FOREIGN_KEY: str +CANNOT_COERCE: str +UNDEFINED_FUNCTION: str +GENERATED_ALWAYS: str +RESERVED_NAME: str +UNDEFINED_TABLE: str +UNDEFINED_PARAMETER: str +DUPLICATE_CURSOR: str +DUPLICATE_DATABASE: str +DUPLICATE_PREPARED_STATEMENT: str +DUPLICATE_SCHEMA: str +DUPLICATE_TABLE: str +AMBIGUOUS_PARAMETER: str +AMBIGUOUS_ALIAS: str +INVALID_COLUMN_REFERENCE: str +INVALID_CURSOR_DEFINITION: str +INVALID_DATABASE_DEFINITION: str +INVALID_FUNCTION_DEFINITION: str +INVALID_PREPARED_STATEMENT_DEFINITION: str +INVALID_SCHEMA_DEFINITION: str +INVALID_TABLE_DEFINITION: str +INVALID_OBJECT_DEFINITION: str +INDETERMINATE_DATATYPE: str +INVALID_RECURSION: str +WINDOWING_ERROR: str +COLLATION_MISMATCH: str +INDETERMINATE_COLLATION: str +WITH_CHECK_OPTION_VIOLATION: str +INSUFFICIENT_RESOURCES: str +DISK_FULL: str +OUT_OF_MEMORY: str +TOO_MANY_CONNECTIONS: str +CONFIGURATION_LIMIT_EXCEEDED: str +PROGRAM_LIMIT_EXCEEDED: str +STATEMENT_TOO_COMPLEX: str +TOO_MANY_COLUMNS: str +TOO_MANY_ARGUMENTS: str +OBJECT_NOT_IN_PREREQUISITE_STATE: str +OBJECT_IN_USE: str +CANT_CHANGE_RUNTIME_PARAM: str +LOCK_NOT_AVAILABLE: str +UNSAFE_NEW_ENUM_VALUE_USAGE: str +OPERATOR_INTERVENTION: str +QUERY_CANCELED: str +ADMIN_SHUTDOWN: str +CRASH_SHUTDOWN: str +CANNOT_CONNECT_NOW: str +DATABASE_DROPPED: str +SYSTEM_ERROR: str +IO_ERROR: str +UNDEFINED_FILE: str +DUPLICATE_FILE: str +SNAPSHOT_TOO_OLD: str +CONFIG_FILE_ERROR: str +LOCK_FILE_EXISTS: str +FDW_ERROR: str +FDW_OUT_OF_MEMORY: str +FDW_DYNAMIC_PARAMETER_VALUE_NEEDED: str +FDW_INVALID_DATA_TYPE: str +FDW_COLUMN_NAME_NOT_FOUND: str +FDW_INVALID_DATA_TYPE_DESCRIPTORS: str +FDW_INVALID_COLUMN_NAME: str +FDW_INVALID_COLUMN_NUMBER: str +FDW_INVALID_USE_OF_NULL_POINTER: str +FDW_INVALID_STRING_FORMAT: str +FDW_INVALID_HANDLE: str +FDW_INVALID_OPTION_INDEX: str +FDW_INVALID_OPTION_NAME: str +FDW_OPTION_NAME_NOT_FOUND: str +FDW_REPLY_HANDLE: str +FDW_UNABLE_TO_CREATE_EXECUTION: str +FDW_UNABLE_TO_CREATE_REPLY: str +FDW_UNABLE_TO_ESTABLISH_CONNECTION: str +FDW_NO_SCHEMAS: str +FDW_SCHEMA_NOT_FOUND: str +FDW_TABLE_NOT_FOUND: str +FDW_FUNCTION_SEQUENCE_ERROR: str +FDW_TOO_MANY_HANDLES: str +FDW_INCONSISTENT_DESCRIPTOR_INFORMATION: str +FDW_INVALID_ATTRIBUTE_VALUE: str +FDW_INVALID_STRING_LENGTH_OR_BUFFER_LENGTH: str +FDW_INVALID_DESCRIPTOR_FIELD_IDENTIFIER: str +PLPGSQL_ERROR: str +RAISE_EXCEPTION: str +NO_DATA_FOUND: str +TOO_MANY_ROWS: str +ASSERT_FAILURE: str +INTERNAL_ERROR: str +DATA_CORRUPTED: str +INDEX_CORRUPTED: str diff --git a/stubs/psycopg2/psycopg2/errors.pyi b/stubs/psycopg2/psycopg2/errors.pyi new file mode 100644 index 000000000..d3793b8b4 --- /dev/null +++ b/stubs/psycopg2/psycopg2/errors.pyi @@ -0,0 +1,276 @@ +from typing import Any + +class Error: + def __init__(self, *args, **kwargs): ... + args: Any + cursor: Any + diag: Any + pgcode: Any + pgerror: Any + with_traceback: Any + +class Warning: + args: Any + with_traceback: Any + +class DatabaseError(Error): ... +class InterfaceError(Error): ... +class DataError(DatabaseError): ... +class DiagnosticsException(DatabaseError): ... +class IntegrityError(DatabaseError): ... +class InternalError(DatabaseError): ... +class InvalidGrantOperation(DatabaseError): ... +class InvalidGrantor(DatabaseError): ... +class InvalidLocatorSpecification(DatabaseError): ... +class InvalidRoleSpecification(DatabaseError): ... +class InvalidTransactionInitiation(DatabaseError): ... +class LocatorException(DatabaseError): ... +class NoAdditionalDynamicResultSetsReturned(DatabaseError): ... +class NoData(DatabaseError): ... +class NotSupportedError(DatabaseError): ... +class OperationalError(DatabaseError): ... +class ProgrammingError(DatabaseError): ... +class SnapshotTooOld(DatabaseError): ... +class SqlStatementNotYetComplete(DatabaseError): ... +class StackedDiagnosticsAccessedWithoutActiveHandler(DatabaseError): ... +class TriggeredActionException(DatabaseError): ... +class ActiveSqlTransaction(InternalError): ... +class AdminShutdown(OperationalError): ... +class AmbiguousAlias(ProgrammingError): ... +class AmbiguousColumn(ProgrammingError): ... +class AmbiguousFunction(ProgrammingError): ... +class AmbiguousParameter(ProgrammingError): ... +class ArraySubscriptError(DataError): ... +class AssertFailure(InternalError): ... +class BadCopyFileFormat(DataError): ... +class BranchTransactionAlreadyActive(InternalError): ... +class CannotCoerce(ProgrammingError): ... +class CannotConnectNow(OperationalError): ... +class CantChangeRuntimeParam(OperationalError): ... +class CardinalityViolation(ProgrammingError): ... +class CaseNotFound(ProgrammingError): ... +class CharacterNotInRepertoire(DataError): ... +class CheckViolation(IntegrityError): ... +class CollationMismatch(ProgrammingError): ... +class ConfigFileError(InternalError): ... +class ConfigurationLimitExceeded(OperationalError): ... +class ConnectionDoesNotExist(OperationalError): ... +class ConnectionException(OperationalError): ... +class ConnectionFailure(OperationalError): ... +class ContainingSqlNotPermitted(InternalError): ... +class CrashShutdown(OperationalError): ... +class DataCorrupted(InternalError): ... +class DataException(DataError): ... +class DatabaseDropped(OperationalError): ... +class DatatypeMismatch(ProgrammingError): ... +class DatetimeFieldOverflow(DataError): ... +class DependentObjectsStillExist(InternalError): ... +class DependentPrivilegeDescriptorsStillExist(InternalError): ... +class DiskFull(OperationalError): ... +class DivisionByZero(DataError): ... +class DuplicateAlias(ProgrammingError): ... +class DuplicateColumn(ProgrammingError): ... +class DuplicateCursor(ProgrammingError): ... +class DuplicateDatabase(ProgrammingError): ... +class DuplicateFile(OperationalError): ... +class DuplicateFunction(ProgrammingError): ... +class DuplicateJsonObjectKeyValue(DataError): ... +class DuplicateObject(ProgrammingError): ... +class DuplicatePreparedStatement(ProgrammingError): ... +class DuplicateSchema(ProgrammingError): ... +class DuplicateTable(ProgrammingError): ... +class ErrorInAssignment(DataError): ... +class EscapeCharacterConflict(DataError): ... +class EventTriggerProtocolViolated(InternalError): ... +class ExclusionViolation(IntegrityError): ... +class ExternalRoutineException(InternalError): ... +class ExternalRoutineInvocationException(InternalError): ... +class FdwColumnNameNotFound(OperationalError): ... +class FdwDynamicParameterValueNeeded(OperationalError): ... +class FdwError(OperationalError): ... +class FdwFunctionSequenceError(OperationalError): ... +class FdwInconsistentDescriptorInformation(OperationalError): ... +class FdwInvalidAttributeValue(OperationalError): ... +class FdwInvalidColumnName(OperationalError): ... +class FdwInvalidColumnNumber(OperationalError): ... +class FdwInvalidDataType(OperationalError): ... +class FdwInvalidDataTypeDescriptors(OperationalError): ... +class FdwInvalidDescriptorFieldIdentifier(OperationalError): ... +class FdwInvalidHandle(OperationalError): ... +class FdwInvalidOptionIndex(OperationalError): ... +class FdwInvalidOptionName(OperationalError): ... +class FdwInvalidStringFormat(OperationalError): ... +class FdwInvalidStringLengthOrBufferLength(OperationalError): ... +class FdwInvalidUseOfNullPointer(OperationalError): ... +class FdwNoSchemas(OperationalError): ... +class FdwOptionNameNotFound(OperationalError): ... +class FdwOutOfMemory(OperationalError): ... +class FdwReplyHandle(OperationalError): ... +class FdwSchemaNotFound(OperationalError): ... +class FdwTableNotFound(OperationalError): ... +class FdwTooManyHandles(OperationalError): ... +class FdwUnableToCreateExecution(OperationalError): ... +class FdwUnableToCreateReply(OperationalError): ... +class FdwUnableToEstablishConnection(OperationalError): ... +class FeatureNotSupported(NotSupportedError): ... +class FloatingPointException(DataError): ... +class ForeignKeyViolation(IntegrityError): ... +class FunctionExecutedNoReturnStatement(InternalError): ... +class GeneratedAlways(ProgrammingError): ... +class GroupingError(ProgrammingError): ... +class HeldCursorRequiresSameIsolationLevel(InternalError): ... +class IdleInTransactionSessionTimeout(InternalError): ... +class InFailedSqlTransaction(InternalError): ... +class InappropriateAccessModeForBranchTransaction(InternalError): ... +class InappropriateIsolationLevelForBranchTransaction(InternalError): ... +class IndeterminateCollation(ProgrammingError): ... +class IndeterminateDatatype(ProgrammingError): ... +class IndexCorrupted(InternalError): ... +class IndicatorOverflow(DataError): ... +class InsufficientPrivilege(ProgrammingError): ... +class InsufficientResources(OperationalError): ... +class IntegrityConstraintViolation(IntegrityError): ... +class InternalError_(InternalError): ... +class IntervalFieldOverflow(DataError): ... +class InvalidArgumentForLogarithm(DataError): ... +class InvalidArgumentForNthValueFunction(DataError): ... +class InvalidArgumentForNtileFunction(DataError): ... +class InvalidArgumentForPowerFunction(DataError): ... +class InvalidArgumentForSqlJsonDatetimeFunction(DataError): ... +class InvalidArgumentForWidthBucketFunction(DataError): ... +class InvalidAuthorizationSpecification(OperationalError): ... +class InvalidBinaryRepresentation(DataError): ... +class InvalidCatalogName(ProgrammingError): ... +class InvalidCharacterValueForCast(DataError): ... +class InvalidColumnDefinition(ProgrammingError): ... +class InvalidColumnReference(ProgrammingError): ... +class InvalidCursorDefinition(ProgrammingError): ... +class InvalidCursorName(OperationalError): ... +class InvalidCursorState(InternalError): ... +class InvalidDatabaseDefinition(ProgrammingError): ... +class InvalidDatetimeFormat(DataError): ... +class InvalidEscapeCharacter(DataError): ... +class InvalidEscapeOctet(DataError): ... +class InvalidEscapeSequence(DataError): ... +class InvalidForeignKey(ProgrammingError): ... +class InvalidFunctionDefinition(ProgrammingError): ... +class InvalidIndicatorParameterValue(DataError): ... +class InvalidJsonText(DataError): ... +class InvalidName(ProgrammingError): ... +class InvalidObjectDefinition(ProgrammingError): ... +class InvalidParameterValue(DataError): ... +class InvalidPassword(OperationalError): ... +class InvalidPrecedingOrFollowingSize(DataError): ... +class InvalidPreparedStatementDefinition(ProgrammingError): ... +class InvalidRecursion(ProgrammingError): ... +class InvalidRegularExpression(DataError): ... +class InvalidRowCountInLimitClause(DataError): ... +class InvalidRowCountInResultOffsetClause(DataError): ... +class InvalidSavepointSpecification(InternalError): ... +class InvalidSchemaDefinition(ProgrammingError): ... +class InvalidSchemaName(ProgrammingError): ... +class InvalidSqlJsonSubscript(DataError): ... +class InvalidSqlStatementName(OperationalError): ... +class InvalidSqlstateReturned(InternalError): ... +class InvalidTableDefinition(ProgrammingError): ... +class InvalidTablesampleArgument(DataError): ... +class InvalidTablesampleRepeat(DataError): ... +class InvalidTextRepresentation(DataError): ... +class InvalidTimeZoneDisplacementValue(DataError): ... +class InvalidTransactionState(InternalError): ... +class InvalidTransactionTermination(InternalError): ... +class InvalidUseOfEscapeCharacter(DataError): ... +class InvalidXmlComment(DataError): ... +class InvalidXmlContent(DataError): ... +class InvalidXmlDocument(DataError): ... +class InvalidXmlProcessingInstruction(DataError): ... +class IoError(OperationalError): ... +class LockFileExists(InternalError): ... +class LockNotAvailable(OperationalError): ... +class ModifyingSqlDataNotPermitted(InternalError): ... +class ModifyingSqlDataNotPermittedExt(InternalError): ... +class MoreThanOneSqlJsonItem(DataError): ... +class MostSpecificTypeMismatch(DataError): ... +class NameTooLong(ProgrammingError): ... +class NoActiveSqlTransaction(InternalError): ... +class NoActiveSqlTransactionForBranchTransaction(InternalError): ... +class NoDataFound(InternalError): ... +class NoSqlJsonItem(DataError): ... +class NonNumericSqlJsonItem(DataError): ... +class NonUniqueKeysInAJsonObject(DataError): ... +class NonstandardUseOfEscapeCharacter(DataError): ... +class NotAnXmlDocument(DataError): ... +class NotNullViolation(IntegrityError): ... +class NullValueNoIndicatorParameter(DataError): ... +class NullValueNotAllowed(DataError): ... +class NullValueNotAllowedExt(InternalError): ... +class NumericValueOutOfRange(DataError): ... +class ObjectInUse(OperationalError): ... +class ObjectNotInPrerequisiteState(OperationalError): ... +class OperatorIntervention(OperationalError): ... +class OutOfMemory(OperationalError): ... +class PlpgsqlError(InternalError): ... +class ProgramLimitExceeded(OperationalError): ... +class ProhibitedSqlStatementAttempted(InternalError): ... +class ProhibitedSqlStatementAttemptedExt(InternalError): ... +class ProtocolViolation(OperationalError): ... +class QueryCanceledError(OperationalError): ... +class RaiseException(InternalError): ... +class ReadOnlySqlTransaction(InternalError): ... +class ReadingSqlDataNotPermitted(InternalError): ... +class ReadingSqlDataNotPermittedExt(InternalError): ... +class ReservedName(ProgrammingError): ... +class RestrictViolation(IntegrityError): ... +class SavepointException(InternalError): ... +class SchemaAndDataStatementMixingNotSupported(InternalError): ... +class SequenceGeneratorLimitExceeded(DataError): ... +class SingletonSqlJsonItemRequired(DataError): ... +class SqlJsonArrayNotFound(DataError): ... +class SqlJsonMemberNotFound(DataError): ... +class SqlJsonNumberNotFound(DataError): ... +class SqlJsonObjectNotFound(DataError): ... +class SqlJsonScalarRequired(DataError): ... +class SqlRoutineException(InternalError): ... +class SqlclientUnableToEstablishSqlconnection(OperationalError): ... +class SqlserverRejectedEstablishmentOfSqlconnection(OperationalError): ... +class SrfProtocolViolated(InternalError): ... +class StatementTooComplex(OperationalError): ... +class StringDataLengthMismatch(DataError): ... +class StringDataRightTruncation(DataError): ... +class SubstringError(DataError): ... +class SyntaxError(ProgrammingError): ... +class SyntaxErrorOrAccessRuleViolation(ProgrammingError): ... +class SystemError(OperationalError): ... +class TooManyArguments(OperationalError): ... +class TooManyColumns(OperationalError): ... +class TooManyConnections(OperationalError): ... +class TooManyJsonArrayElements(DataError): ... +class TooManyJsonObjectMembers(DataError): ... +class TooManyRows(InternalError): ... +class TransactionResolutionUnknown(OperationalError): ... +class TransactionRollbackError(OperationalError): ... +class TriggerProtocolViolated(InternalError): ... +class TriggeredDataChangeViolation(OperationalError): ... +class TrimError(DataError): ... +class UndefinedColumn(ProgrammingError): ... +class UndefinedFile(OperationalError): ... +class UndefinedFunction(ProgrammingError): ... +class UndefinedObject(ProgrammingError): ... +class UndefinedParameter(ProgrammingError): ... +class UndefinedTable(ProgrammingError): ... +class UniqueViolation(IntegrityError): ... +class UnsafeNewEnumValueUsage(OperationalError): ... +class UnterminatedCString(DataError): ... +class UntranslatableCharacter(DataError): ... +class WindowingError(ProgrammingError): ... +class WithCheckOptionViolation(ProgrammingError): ... +class WrongObjectType(ProgrammingError): ... +class ZeroLengthCharacterString(DataError): ... +class DeadlockDetected(TransactionRollbackError): ... +class QueryCanceled(QueryCanceledError): ... +class SerializationFailure(TransactionRollbackError): ... +class StatementCompletionUnknown(TransactionRollbackError): ... +class TransactionIntegrityConstraintViolation(TransactionRollbackError): ... +class TransactionRollback(TransactionRollbackError): ... + +def lookup(code): ... diff --git a/stubs/psycopg2/psycopg2/extensions.pyi b/stubs/psycopg2/psycopg2/extensions.pyi new file mode 100644 index 000000000..634f07d27 --- /dev/null +++ b/stubs/psycopg2/psycopg2/extensions.pyi @@ -0,0 +1,114 @@ +from typing import Any + +from psycopg2._psycopg import ( + BINARYARRAY as BINARYARRAY, + BOOLEAN as BOOLEAN, + BOOLEANARRAY as BOOLEANARRAY, + BYTES as BYTES, + BYTESARRAY as BYTESARRAY, + DATE as DATE, + DATEARRAY as DATEARRAY, + DATETIMEARRAY as DATETIMEARRAY, + DECIMAL as DECIMAL, + DECIMALARRAY as DECIMALARRAY, + FLOAT as FLOAT, + FLOATARRAY as FLOATARRAY, + INTEGER as INTEGER, + INTEGERARRAY as INTEGERARRAY, + INTERVAL as INTERVAL, + INTERVALARRAY as INTERVALARRAY, + LONGINTEGER as LONGINTEGER, + LONGINTEGERARRAY as LONGINTEGERARRAY, + PYDATE as PYDATE, + PYDATEARRAY as PYDATEARRAY, + PYDATETIME as PYDATETIME, + PYDATETIMEARRAY as PYDATETIMEARRAY, + PYDATETIMETZ as PYDATETIMETZ, + PYDATETIMETZARRAY as PYDATETIMETZARRAY, + PYINTERVAL as PYINTERVAL, + PYINTERVALARRAY as PYINTERVALARRAY, + PYTIME as PYTIME, + PYTIMEARRAY as PYTIMEARRAY, + ROWIDARRAY as ROWIDARRAY, + STRINGARRAY as STRINGARRAY, + TIME as TIME, + TIMEARRAY as TIMEARRAY, + UNICODE as UNICODE, + UNICODEARRAY as UNICODEARRAY, + AsIs as AsIs, + Binary as Binary, + Boolean as Boolean, + Column as Column, + ConnectionInfo as ConnectionInfo, + DateFromPy as DateFromPy, + Diagnostics as Diagnostics, + Float as Float, + Int as Int, + IntervalFromPy as IntervalFromPy, + ISQLQuote as ISQLQuote, + Notify as Notify, + QueryCanceledError as QueryCanceledError, + QuotedString as QuotedString, + TimeFromPy as TimeFromPy, + TimestampFromPy as TimestampFromPy, + TransactionRollbackError as TransactionRollbackError, + Xid as Xid, + adapt as adapt, + adapters as adapters, + binary_types as binary_types, + connection as connection, + cursor as cursor, + encodings as encodings, + encrypt_password as encrypt_password, + get_wait_callback as get_wait_callback, + libpq_version as libpq_version, + lobject as lobject, + new_array_type as new_array_type, + new_type as new_type, + parse_dsn as parse_dsn, + quote_ident as quote_ident, + register_type as register_type, + set_wait_callback as set_wait_callback, + string_types as string_types, +) + +ISOLATION_LEVEL_AUTOCOMMIT: int +ISOLATION_LEVEL_READ_UNCOMMITTED: int +ISOLATION_LEVEL_READ_COMMITTED: int +ISOLATION_LEVEL_REPEATABLE_READ: int +ISOLATION_LEVEL_SERIALIZABLE: int +ISOLATION_LEVEL_DEFAULT: Any +STATUS_SETUP: int +STATUS_READY: int +STATUS_BEGIN: int +STATUS_SYNC: int +STATUS_ASYNC: int +STATUS_PREPARED: int +STATUS_IN_TRANSACTION: int +POLL_OK: int +POLL_READ: int +POLL_WRITE: int +POLL_ERROR: int +TRANSACTION_STATUS_IDLE: int +TRANSACTION_STATUS_ACTIVE: int +TRANSACTION_STATUS_INTRANS: int +TRANSACTION_STATUS_INERROR: int +TRANSACTION_STATUS_UNKNOWN: int + +def register_adapter(typ, callable) -> None: ... + +class SQL_IN: + def __init__(self, seq) -> None: ... + def prepare(self, conn) -> None: ... + def getquoted(self): ... + +class NoneAdapter: + def __init__(self, obj) -> None: ... + def getquoted(self, _null: bytes = ...): ... + +def make_dsn(dsn: Any | None = ..., **kwargs): ... + +JSON: Any +JSONARRAY: Any +JSONB: Any +JSONBARRAY: Any diff --git a/stubs/psycopg2/psycopg2/extras.pyi b/stubs/psycopg2/psycopg2/extras.pyi new file mode 100644 index 000000000..364de1a2f --- /dev/null +++ b/stubs/psycopg2/psycopg2/extras.pyi @@ -0,0 +1,181 @@ +from collections import OrderedDict +from typing import Any, List + +from psycopg2._ipaddress import register_ipaddress as register_ipaddress +from psycopg2._json import ( + Json as Json, + register_default_json as register_default_json, + register_default_jsonb as register_default_jsonb, + register_json as register_json, +) +from psycopg2._psycopg import ( + REPLICATION_LOGICAL as REPLICATION_LOGICAL, + REPLICATION_PHYSICAL as REPLICATION_PHYSICAL, + ReplicationConnection as _replicationConnection, + ReplicationCursor as _replicationCursor, + ReplicationMessage as ReplicationMessage, +) +from psycopg2._range import ( + DateRange as DateRange, + DateTimeRange as DateTimeRange, + DateTimeTZRange as DateTimeTZRange, + NumericRange as NumericRange, + Range as Range, + RangeAdapter as RangeAdapter, + RangeCaster as RangeCaster, + register_range as register_range, +) + +from .extensions import connection as _connection, cursor as _cursor, quote_ident as quote_ident + +class DictCursorBase(_cursor): + row_factory: Any + def __init__(self, *args, **kwargs) -> None: ... + def fetchone(self): ... + def fetchmany(self, size: Any | None = ...): ... + def fetchall(self): ... + def __iter__(self): ... + +class DictConnection(_connection): + def cursor(self, *args, **kwargs): ... + +class DictCursor(DictCursorBase): + def __init__(self, *args, **kwargs) -> None: ... + index: Any + def execute(self, query, vars: Any | None = ...): ... + def callproc(self, procname, vars: Any | None = ...): ... + +class DictRow(List[Any]): + def __init__(self, cursor) -> None: ... + def __getitem__(self, x): ... + def __setitem__(self, x, v) -> None: ... + def items(self): ... + def keys(self): ... + def values(self): ... + def get(self, x, default: Any | None = ...): ... + def copy(self): ... + def __contains__(self, x): ... + def __reduce__(self): ... + +class RealDictConnection(_connection): + def cursor(self, *args, **kwargs): ... + +class RealDictCursor(DictCursorBase): + def __init__(self, *args, **kwargs) -> None: ... + column_mapping: Any + def execute(self, query, vars: Any | None = ...): ... + def callproc(self, procname, vars: Any | None = ...): ... + +class RealDictRow(OrderedDict[Any, Any]): + def __init__(self, *args, **kwargs) -> None: ... + def __setitem__(self, key, value) -> None: ... + +class NamedTupleConnection(_connection): + def cursor(self, *args, **kwargs): ... + +class NamedTupleCursor(_cursor): + Record: Any + MAX_CACHE: int + def execute(self, query, vars: Any | None = ...): ... + def executemany(self, query, vars): ... + def callproc(self, procname, vars: Any | None = ...): ... + def fetchone(self): ... + def fetchmany(self, size: Any | None = ...): ... + def fetchall(self): ... + def __iter__(self): ... + +class LoggingConnection(_connection): + log: Any + def initialize(self, logobj) -> None: ... + def filter(self, msg, curs): ... + def cursor(self, *args, **kwargs): ... + +class LoggingCursor(_cursor): + def execute(self, query, vars: Any | None = ...): ... + def callproc(self, procname, vars: Any | None = ...): ... + +class MinTimeLoggingConnection(LoggingConnection): + def initialize(self, logobj, mintime: int = ...) -> None: ... + def filter(self, msg, curs): ... + def cursor(self, *args, **kwargs): ... + +class MinTimeLoggingCursor(LoggingCursor): + timestamp: Any + def execute(self, query, vars: Any | None = ...): ... + def callproc(self, procname, vars: Any | None = ...): ... + +class LogicalReplicationConnection(_replicationConnection): + def __init__(self, *args, **kwargs) -> None: ... + +class PhysicalReplicationConnection(_replicationConnection): + def __init__(self, *args, **kwargs) -> None: ... + +class StopReplication(Exception): ... + +class ReplicationCursor(_replicationCursor): + def create_replication_slot(self, slot_name, slot_type: Any | None = ..., output_plugin: Any | None = ...) -> None: ... + def drop_replication_slot(self, slot_name) -> None: ... + def start_replication( + self, + slot_name: Any | None = ..., + slot_type: Any | None = ..., + start_lsn: int = ..., + timeline: int = ..., + options: Any | None = ..., + decode: bool = ..., + status_interval: int = ..., + ) -> None: ... + def fileno(self): ... + +class UUID_adapter: + def __init__(self, uuid) -> None: ... + def __conform__(self, proto): ... + def getquoted(self): ... + +def register_uuid(oids: Any | None = ..., conn_or_curs: Any | None = ...): ... + +class Inet: + addr: Any + def __init__(self, addr) -> None: ... + def prepare(self, conn) -> None: ... + def getquoted(self): ... + def __conform__(self, proto): ... + +def register_inet(oid: Any | None = ..., conn_or_curs: Any | None = ...): ... +def wait_select(conn) -> None: ... + +class HstoreAdapter: + wrapped: Any + def __init__(self, wrapped) -> None: ... + conn: Any + getquoted: Any + def prepare(self, conn) -> None: ... + @classmethod + def parse(cls, s, cur, _bsdec=...): ... + @classmethod + def parse_unicode(cls, s, cur): ... + @classmethod + def get_oids(cls, conn_or_curs): ... + +def register_hstore( + conn_or_curs, globally: bool = ..., unicode: bool = ..., oid: Any | None = ..., array_oid: Any | None = ... +) -> None: ... + +class CompositeCaster: + name: Any + schema: Any + oid: Any + array_oid: Any + attnames: Any + atttypes: Any + typecaster: Any + array_typecaster: Any + def __init__(self, name, oid, attrs, array_oid: Any | None = ..., schema: Any | None = ...) -> None: ... + def parse(self, s, curs): ... + def make(self, values): ... + @classmethod + def tokenize(cls, s): ... + +def register_composite(name, conn_or_curs, globally: bool = ..., factory: Any | None = ...): ... +def execute_batch(cur, sql, argslist, page_size: int = ...) -> None: ... +def execute_values(cur, sql, argslist, template: Any | None = ..., page_size: int = ..., fetch: bool = ...): ... diff --git a/stubs/psycopg2/psycopg2/pool.pyi b/stubs/psycopg2/psycopg2/pool.pyi new file mode 100644 index 000000000..b3aee45a6 --- /dev/null +++ b/stubs/psycopg2/psycopg2/pool.pyi @@ -0,0 +1,22 @@ +from typing import Any + +import psycopg2 + +class PoolError(psycopg2.Error): ... + +class AbstractConnectionPool: + minconn: Any + maxconn: Any + closed: bool + def __init__(self, minconn, maxconn, *args, **kwargs) -> None: ... + +class SimpleConnectionPool(AbstractConnectionPool): + getconn: Any + putconn: Any + closeall: Any + +class ThreadedConnectionPool(AbstractConnectionPool): + def __init__(self, minconn, maxconn, *args, **kwargs) -> None: ... + def getconn(self, key: Any | None = ...): ... + def putconn(self, conn: Any | None = ..., key: Any | None = ..., close: bool = ...) -> None: ... + def closeall(self) -> None: ... diff --git a/stubs/psycopg2/psycopg2/sql.pyi b/stubs/psycopg2/psycopg2/sql.pyi new file mode 100644 index 000000000..be30d720f --- /dev/null +++ b/stubs/psycopg2/psycopg2/sql.pyi @@ -0,0 +1,48 @@ +from typing import Any + +class Composable: + def __init__(self, wrapped) -> None: ... + def as_string(self, context) -> None: ... + def __add__(self, other): ... + def __mul__(self, n): ... + def __eq__(self, other): ... + def __ne__(self, other): ... + +class Composed(Composable): + def __init__(self, seq) -> None: ... + @property + def seq(self): ... + def as_string(self, context): ... + def __iter__(self): ... + def __add__(self, other): ... + def join(self, joiner): ... + +class SQL(Composable): + def __init__(self, string) -> None: ... + @property + def string(self): ... + def as_string(self, context): ... + def format(self, *args, **kwargs): ... + def join(self, seq): ... + +class Identifier(Composable): + def __init__(self, *strings) -> None: ... + @property + def strings(self): ... + @property + def string(self): ... + def as_string(self, context): ... + +class Literal(Composable): + @property + def wrapped(self): ... + def as_string(self, context): ... + +class Placeholder(Composable): + def __init__(self, name: Any | None = ...) -> None: ... + @property + def name(self): ... + def as_string(self, context): ... + +NULL: Any +DEFAULT: Any diff --git a/stubs/psycopg2/psycopg2/tz.pyi b/stubs/psycopg2/psycopg2/tz.pyi new file mode 100644 index 000000000..613e41132 --- /dev/null +++ b/stubs/psycopg2/psycopg2/tz.pyi @@ -0,0 +1,25 @@ +import datetime +from typing import Any + +ZERO: Any + +class FixedOffsetTimezone(datetime.tzinfo): + def __init__(self, offset: Any | None = ..., name: Any | None = ...) -> None: ... + def __new__(cls, offset: Any | None = ..., name: Any | None = ...): ... + def __eq__(self, other): ... + def __ne__(self, other): ... + def __getinitargs__(self): ... + def utcoffset(self, dt): ... + def tzname(self, dt): ... + def dst(self, dt): ... + +STDOFFSET: Any +DSTOFFSET: Any +DSTDIFF: Any + +class LocalTimezone(datetime.tzinfo): + def utcoffset(self, dt): ... + def dst(self, dt): ... + def tzname(self, dt): ... + +LOCAL: Any