]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Some mypy cleanup
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Wed, 24 Jun 2020 14:17:20 +0000 (02:17 +1200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Tue, 30 Jun 2020 18:42:05 +0000 (06:42 +1200)
psycopg3/_psycopg3.pyi
psycopg3/adapt.py
psycopg3/proto.py
psycopg3/transform.pyx

index ca26da420f831f419639e22c428650c65f7a9a76..87cd90596116f44093917eb349681fc1f11879dc 100644 (file)
@@ -15,8 +15,6 @@ from .proto import LoadFunc, LoadersMap, LoaderType, MaybeOid, PQGen
 from .connection import BaseConnection
 from . import pq
 
-Format = pq.Format
-
 class Transformer:
     def __init__(self, context: AdaptContext = None): ...
     @property
@@ -28,25 +26,29 @@ class Transformer:
     @property
     def loaders(self) -> LoadersMap: ...
     @property
-    def pgresult(self) -> Optional["pq.proto.PGresult"]: ...
+    def pgresult(self) -> Optional[pq.proto.PGresult]: ...
     @pgresult.setter
-    def pgresult(self, result: Optional["pq.proto.PGresult"]) -> None: ...
-    def set_row_types(self, types: Sequence[Tuple[int, Format]]) -> None: ...
+    def pgresult(self, result: Optional[pq.proto.PGresult]) -> None: ...
+    def set_row_types(
+        self, types: Sequence[Tuple[int, pq.Format]]
+    ) -> None: ...
     def dump_sequence(
-        self, objs: Iterable[Any], formats: Iterable[Format]
+        self, objs: Iterable[Any], formats: Iterable[pq.Format]
     ) -> Tuple[List[Optional[bytes]], List[int]]: ...
-    def dump(self, obj: None, format: Format = Format.TEXT) -> MaybeOid: ...
-    def get_dump_function(self, src: type, format: Format) -> DumpFunc: ...
-    def lookup_dumper(self, src: type, format: Format) -> DumperType: ...
+    def dump(
+        self, obj: None, format: pq.Format = pq.Format.TEXT
+    ) -> MaybeOid: ...
+    def get_dump_function(self, src: type, format: pq.Format) -> DumpFunc: ...
+    def lookup_dumper(self, src: type, format: pq.Format) -> DumperType: ...
     def load_row(self, row: int) -> Optional[Tuple[Any, ...]]: ...
     def load_sequence(
         self, record: Sequence[Optional[bytes]]
     ) -> Tuple[Any, ...]: ...
     def load(
-        self, data: bytes, oid: int, format: Format = Format.TEXT
+        self, data: bytes, oid: int, format: pq.Format = pq.Format.TEXT
     ) -> Any: ...
-    def get_load_function(self, oid: int, format: Format) -> LoadFunc: ...
-    def lookup_loader(self, oid: int, format: Format) -> LoaderType: ...
+    def get_load_function(self, oid: int, format: pq.Format) -> LoadFunc: ...
+    def lookup_loader(self, oid: int, format: pq.Format) -> LoaderType: ...
 
 def register_builtin_c_loaders() -> None: ...
 def connect(conninfo: str) -> PQGen[pq.proto.PGconn]: ...
index cd97715b108565b4d7daa33dcd05ea38637d0651..d3fc9c78d65e527a7457e3abe8932377143aac5a 100644 (file)
@@ -8,14 +8,12 @@ from typing import Any, Callable, Optional, Tuple, Type, Union
 
 from . import pq
 from . import proto
+from .pq import Format as Format
 from .proto import AdaptContext, DumpersMap, DumperType
 from .proto import LoadersMap, LoaderType
 from .cursor import BaseCursor
 from .connection import BaseConnection
 
-# Part of the module interface (just importing it makes mypy unhappy)
-Format = pq.Format
-
 
 class Dumper:
     globals: DumpersMap = {}
index edf6f32836f3471cc67533ff88a8dc5235744ef0..1a4ac3140696a7ce105a98f953bb6c21a675c86e 100644 (file)
@@ -11,15 +11,13 @@ from typing import TYPE_CHECKING
 from typing_extensions import Protocol
 
 from . import pq
+from .pq import Format
 
 if TYPE_CHECKING:
-    from .connection import BaseConnection  # noqa
-    from .cursor import BaseCursor  # noqa
-    from .adapt import Dumper, Loader  # noqa
-    from .waiting import Wait, Ready  # noqa
-
-# Part of the module interface (just importing it makes mypy unhappy)
-Format = pq.Format
+    from .connection import BaseConnection
+    from .cursor import BaseCursor
+    from .adapt import Dumper, Loader
+    from .waiting import Wait, Ready
 
 EncodeFunc = Callable[[str], Tuple[bytes, int]]
 DecodeFunc = Callable[[bytes], Tuple[str, int]]
@@ -61,11 +59,11 @@ class Transformer(Protocol):
         ...
 
     @property
-    def pgresult(self) -> Optional["pq.proto.PGresult"]:
+    def pgresult(self) -> Optional[pq.proto.PGresult]:
         ...
 
     @pgresult.setter
-    def pgresult(self, result: Optional["pq.proto.PGresult"]) -> None:
+    def pgresult(self, result: Optional[pq.proto.PGresult]) -> None:
         ...
 
     @property
index d184867ae09f0f63d12fcb96a2a1a8780c0abb41..63205cb864711457296c06d400400bb5cce0c97d 100644 (file)
@@ -149,11 +149,11 @@ cdef class Transformer:
         return self._loaders
 
     @property
-    def pgresult(self) -> Optional["pq.proto.PGresult"]:
+    def pgresult(self) -> Optional[PGresult]:
         return self._pgresult
 
     @pgresult.setter
-    def pgresult(self, result: Optional["pq.proto.PGresult"]) -> None:
+    def pgresult(self, result: Optional[PGresult]) -> None:
         self._pgresult = result
 
         if result is None: