@@ -2,7 +2,7 @@ import datetime as dt
2
2
from _typeshed import ConvertibleToInt , Incomplete , SupportsRead , SupportsReadline , SupportsWrite , Unused
3
3
from collections .abc import Callable , Iterable , Mapping , Sequence
4
4
from types import TracebackType
5
- from typing import Any , Literal , NoReturn , Protocol , TypeVar , overload , type_check_only
5
+ from typing import Any , Literal , NoReturn , Protocol , TextIO , TypeVar , overload , type_check_only
6
6
from typing_extensions import Self , TypeAlias
7
7
8
8
from psycopg2 .extras import ReplicationCursor as extras_ReplicationCursor
@@ -83,7 +83,9 @@ threadsafety: int
83
83
84
84
__libpq_version__ : int
85
85
86
- class _SupportsReadAndReadline (SupportsRead [str ], SupportsReadline [str ], Protocol ): ...
86
+ _T_co = TypeVar ("_T_co" , covariant = True )
87
+
88
+ class _SupportsReadAndReadline (SupportsRead [_T_co ], SupportsReadline [_T_co ], Protocol [_T_co ]): ...
87
89
88
90
class cursor :
89
91
arraysize : int
@@ -120,19 +122,27 @@ class cursor:
120
122
def cast (self , oid : int , s : str | bytes , / ) -> Any : ...
121
123
def close (self ) -> None : ...
122
124
def copy_expert (
123
- self , sql : str | bytes | Composable , file : _SupportsReadAndReadline | SupportsWrite [str ], size : int = 8192
125
+ self ,
126
+ sql : str | bytes | Composable ,
127
+ file : _SupportsReadAndReadline [bytes ] | SupportsWrite [bytes ] | TextIO ,
128
+ size : int = 8192 ,
124
129
) -> None : ...
125
130
def copy_from (
126
131
self ,
127
- file : _SupportsReadAndReadline ,
132
+ file : _SupportsReadAndReadline [ bytes ] | _SupportsReadAndReadline [ str ] ,
128
133
table : str ,
129
134
sep : str = "\t " ,
130
135
null : str = "\\ N" ,
131
136
size : int = 8192 ,
132
137
columns : Iterable [str ] | None = None ,
133
138
) -> None : ...
134
139
def copy_to (
135
- self , file : SupportsWrite [str ], table : str , sep : str = "\t " , null : str = "\\ N" , columns : Iterable [str ] | None = None
140
+ self ,
141
+ file : SupportsWrite [bytes ] | TextIO ,
142
+ table : str ,
143
+ sep : str = "\t " ,
144
+ null : str = "\\ N" ,
145
+ columns : Iterable [str ] | None = None ,
136
146
) -> None : ...
137
147
def execute (self , query : str | bytes | Composable , vars : _Vars = None ) -> None : ...
138
148
def executemany (self , query : str | bytes | Composable , vars_list : Iterable [_Vars ]) -> None : ...
0 commit comments