9
9
import ctypes .util
10
10
from ctypes import Structure , CFUNCTYPE , POINTER
11
11
from ctypes import c_char , c_char_p , c_int , c_size_t , c_ubyte , c_uint , c_void_p
12
- from typing import List , Optional , Tuple
12
+ from typing import Any , List , Optional , Tuple
13
13
14
14
from .misc import find_libpq_full_path
15
15
from ..errors import NotSupportedError
@@ -200,7 +200,8 @@ def PQhostaddr(pgconn: PGconn_struct) -> bytes:
200
200
f" { libpq_version } available instead"
201
201
)
202
202
203
- return _PQhostaddr (pgconn )
203
+ rv : bytes = _PQhostaddr (pgconn )
204
+ return rv
204
205
205
206
206
207
PQport = pq .PQport
@@ -324,7 +325,8 @@ def PQclosePrepared(pgconn: PGconn_struct, name: str) -> int:
324
325
"PQclosePrepared requires libpq from PostgreSQL 17,"
325
326
f" { libpq_version } available instead"
326
327
)
327
- return _PQclosePrepared (pgconn , name )
328
+ rv : int = _PQclosePrepared (pgconn , name )
329
+ return rv
328
330
329
331
330
332
def PQclosePortal (pgconn : PGconn_struct , name : str ) -> int :
@@ -333,7 +335,8 @@ def PQclosePortal(pgconn: PGconn_struct, name: str) -> int:
333
335
"PQclosePortal requires libpq from PostgreSQL 17,"
334
336
f" { libpq_version } available instead"
335
337
)
336
- return _PQclosePortal (pgconn , name )
338
+ rv : int = _PQclosePortal (pgconn , name )
339
+ return rv
337
340
338
341
339
342
PQresultStatus = pq .PQresultStatus
@@ -548,7 +551,8 @@ def PQsendClosePrepared(pgconn: PGconn_struct, name: str) -> int:
548
551
"PQsendClosePrepared requires libpq from PostgreSQL 17,"
549
552
f" { libpq_version } available instead"
550
553
)
551
- return _PQsendClosePrepared (pgconn , name )
554
+ rv : int = _PQsendClosePrepared (pgconn , name )
555
+ return rv
552
556
553
557
554
558
def PQsendClosePortal (pgconn : PGconn_struct , name : str ) -> int :
@@ -557,7 +561,8 @@ def PQsendClosePortal(pgconn: PGconn_struct, name: str) -> int:
557
561
"PQsendClosePortal requires libpq from PostgreSQL 17,"
558
562
f" { libpq_version } available instead"
559
563
)
560
- return _PQsendClosePortal (pgconn , name )
564
+ rv : int = _PQsendClosePortal (pgconn , name )
565
+ return rv
561
566
562
567
563
568
PQgetResult = pq .PQgetResult
@@ -683,7 +688,8 @@ def PQencryptPasswordConn(
683
688
f" { libpq_version } available instead"
684
689
)
685
690
686
- return _PQencryptPasswordConn (pgconn , passwd , user , algorithm )
691
+ rv : Optional [bytes ] = _PQencryptPasswordConn (pgconn , passwd , user , algorithm )
692
+ return rv
687
693
688
694
689
695
PQmakeEmptyPGresult = pq .PQmakeEmptyPGresult
@@ -739,7 +745,8 @@ def PQpipelineStatus(pgconn: PGconn_struct) -> int:
739
745
"PQpipelineStatus requires libpq from PostgreSQL 14,"
740
746
f" { libpq_version } available instead"
741
747
)
742
- return _PQpipelineStatus (pgconn )
748
+ rv : int = _PQpipelineStatus (pgconn )
749
+ return rv
743
750
744
751
745
752
def PQenterPipelineMode (pgconn : PGconn_struct ) -> int :
@@ -748,7 +755,8 @@ def PQenterPipelineMode(pgconn: PGconn_struct) -> int:
748
755
"PQenterPipelineMode requires libpq from PostgreSQL 14,"
749
756
f" { libpq_version } available instead"
750
757
)
751
- return _PQenterPipelineMode (pgconn )
758
+ rv : int = _PQenterPipelineMode (pgconn )
759
+ return rv
752
760
753
761
754
762
def PQexitPipelineMode (pgconn : PGconn_struct ) -> int :
@@ -757,7 +765,8 @@ def PQexitPipelineMode(pgconn: PGconn_struct) -> int:
757
765
"PQexitPipelineMode requires libpq from PostgreSQL 14,"
758
766
f" { libpq_version } available instead"
759
767
)
760
- return _PQexitPipelineMode (pgconn )
768
+ rv : int = _PQexitPipelineMode (pgconn )
769
+ return rv
761
770
762
771
763
772
def PQpipelineSync (pgconn : PGconn_struct ) -> int :
@@ -766,7 +775,8 @@ def PQpipelineSync(pgconn: PGconn_struct) -> int:
766
775
"PQpipelineSync requires libpq from PostgreSQL 14,"
767
776
f" { libpq_version } available instead"
768
777
)
769
- return _PQpipelineSync (pgconn )
778
+ rv : int = _PQpipelineSync (pgconn )
779
+ return rv
770
780
771
781
772
782
def PQsendFlushRequest (pgconn : PGconn_struct ) -> int :
@@ -775,7 +785,8 @@ def PQsendFlushRequest(pgconn: PGconn_struct) -> int:
775
785
"PQsendFlushRequest requires libpq from PostgreSQL 14,"
776
786
f" { libpq_version } available instead"
777
787
)
778
- return _PQsendFlushRequest (pgconn )
788
+ rv : int = _PQsendFlushRequest (pgconn )
789
+ return rv
779
790
780
791
781
792
# 33.18. SSL Support
@@ -787,9 +798,9 @@ def PQsendFlushRequest(pgconn: PGconn_struct) -> int:
787
798
788
799
def generate_stub () -> None :
789
800
import re
790
- from ctypes import _CFuncPtr # type: ignore
801
+ from ctypes import _CFuncPtr # type: ignore[attr-defined]
791
802
792
- def type2str (fname , narg , t ) :
803
+ def type2str (fname : str , narg : int | None , t : Any ) -> str :
793
804
if t is None :
794
805
return "None"
795
806
elif t is c_void_p :
@@ -810,7 +821,7 @@ def type2str(fname, narg, t):
810
821
if narg is not None :
811
822
return f"Optional[{ t .__name__ [3 :]} ]"
812
823
else :
813
- return t .__name__ [3 :]
824
+ return str ( t .__name__ [3 :])
814
825
815
826
elif t .__name__ in ("LP_PQconninfoOption_struct" ,):
816
827
return f"Sequence[{ t .__name__ [3 :]} ]"
0 commit comments