mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-09 21:46:42 +08:00
psycopg2: Fix missing Protocol base class in file protocols (#10943)
This is an error I introduced in #10630 because I didn't know protocols need to be explicitly inherited from in other protocol subclasses. The added test shows the change. Basically these protocols were unusable.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import io
|
||||
from typing_extensions import assert_type
|
||||
|
||||
import psycopg2.extensions
|
||||
@@ -54,3 +55,8 @@ assert_type(dconn.cursor("test-dcur"), psycopg2.extras.DictCursor)
|
||||
assert_type(dconn.cursor("test-dcur", None), psycopg2.extras.DictCursor)
|
||||
assert_type(dconn.cursor("test-dcur", cursor_factory=None), psycopg2.extras.DictCursor)
|
||||
assert_type(dconn.cursor("test-dcur", cursor_factory=MyCursor), MyCursor)
|
||||
|
||||
# file protocols
|
||||
# --------------
|
||||
cur = conn.cursor()
|
||||
cur.copy_from(io.StringIO(), "table")
|
||||
|
||||
@@ -83,8 +83,8 @@ threadsafety: int
|
||||
|
||||
__libpq_version__: int
|
||||
|
||||
class _SupportsReadAndReadline(SupportsRead[str], SupportsReadline[str]): ...
|
||||
class _SupportsReadAndReadlineAndWrite(_SupportsReadAndReadline, SupportsWrite[str]): ...
|
||||
class _SupportsReadAndReadline(SupportsRead[str], SupportsReadline[str], Protocol): ...
|
||||
class _SupportsReadAndReadlineAndWrite(_SupportsReadAndReadline, SupportsWrite[str], Protocol): ...
|
||||
|
||||
class cursor:
|
||||
arraysize: int
|
||||
|
||||
Reference in New Issue
Block a user