]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
chore: bump mypy to 0.990
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Thu, 3 Nov 2022 23:16:10 +0000 (00:16 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Tue, 8 Nov 2022 13:15:01 +0000 (14:15 +0100)
psycopg/psycopg/copy.py
psycopg/psycopg/pq/misc.py
psycopg/psycopg/pq/pq_ctypes.py
psycopg/psycopg/types/enum.py
psycopg/psycopg/types/net.py
psycopg/psycopg/types/uuid.py
psycopg/setup.py
pyproject.toml

index 1313a9a71341857723a01b899c7c35e997b14a9d..274b200833e72026ec241a01c82a8935986414b3 100644 (file)
@@ -461,7 +461,7 @@ class FileWriter(Writer):
         self.file = file
 
     def write(self, data: Buffer) -> None:
-        self.file.write(data)
+        self.file.write(data)  # type: ignore[arg-type]
 
 
 class AsyncCopy(BaseCopy["AsyncConnection[Any]"]):
@@ -831,8 +831,8 @@ def _format_row_binary(
 def _parse_row_text(data: Buffer, tx: Transformer) -> Tuple[Any, ...]:
     if not isinstance(data, bytes):
         data = bytes(data)
-    fields = data.split(b"\t")  # type: ignore
-    fields[-1] = fields[-1][:-1]  # type: ignore  # drop \n
+    fields = data.split(b"\t")
+    fields[-1] = fields[-1][:-1]  # drop \n
     row = [None if f == b"\\N" else _load_re.sub(_load_sub, f) for f in fields]
     return tx.load_sequence(row)
 
index d3da88cade5d426c6c90df4a8c187aa4b778c2a4..3a43133ce91fba15ef0c70462b1be47369163478 100644 (file)
@@ -96,7 +96,6 @@ def error_message(obj: Union[PGconn, PGresult], encoding: str = "utf8") -> str:
 
     elif hasattr(obj, "error_message"):
         # obj is a PGconn
-        obj = cast(PGconn, obj)
         if obj.status == OK:
             encoding = pgconn_encoding(obj)
         bmsg = obj.error_message
index 51462fea85acb2d5270a8bf32be01b5b8ea15c04..8b87c19f41f313ed851786367a9495c6732a7501 100644 (file)
@@ -364,9 +364,7 @@ class PGconn:
             aparams = (c_char_p * nparams)(
                 *(
                     # convert bytearray/memoryview to bytes
-                    b
-                    if b is None or isinstance(b, bytes)
-                    else bytes(b)  # type: ignore[arg-type]
+                    b if b is None or isinstance(b, bytes) else bytes(b)
                     for b in param_values
                 )
             )
index 94d833739cf6cd23c79cbf3c7accac6418fdf4ae..3e195443ddb61c0e848fab7deeb7ccc523c06a2b 100644 (file)
@@ -37,7 +37,7 @@ class _BaseEnumLoader(Loader, Generic[E]):
             return self._load_map[data]
         except KeyError:
             enc = conn_encoding(self.connection)
-            label = data.decode(enc, "replace")  # type: ignore[union-attr]
+            label = data.decode(enc, "replace")
             raise e.DataError(
                 f"bad member for enum {self.enum.__qualname__}: {label!r}"
             )
index 1fdad84fc9a0f15aa4d469aa3df946bdb066b05a..b07cfb696a09d582802d6cedb21c6da0c95ee793 100644 (file)
@@ -42,7 +42,7 @@ class _LazyIpaddress:
         global IPv4Address, IPv6Address, IPv4Interface, IPv6Interface
         global IPv4Network, IPv6Network
 
-        if not ip_address:
+        if ip_address is None:
             from ipaddress import ip_address, ip_interface, ip_network
             from ipaddress import IPv4Address, IPv6Address
             from ipaddress import IPv4Interface, IPv6Interface
index 9cacef6d688f8766e96f28d1b8d1dfd5c539db36..f92354c358f86e85d76ed69b39c7f05f94aa968e 100644 (file)
@@ -38,7 +38,7 @@ class UUIDLoader(Loader):
     def __init__(self, oid: int, context: Optional[AdaptContext] = None):
         super().__init__(oid, context)
         global UUID
-        if not UUID:
+        if UUID is None:
             from uuid import UUID
 
     def load(self, data: Buffer) -> "uuid.UUID":
index fb041efd1007799f30caab4722e4e3692d5dd6e7..edb2b3501af9fd15f8afe3995791fa86063fc5a3 100644 (file)
@@ -37,7 +37,7 @@ extras_require = {
     ],
     # Requirements to run the test suite
     "test": [
-        "mypy >= 0.981",
+        "mypy >= 0.990",
         "pproxy >= 2.7",
         "pytest >= 6.2.5",
         "pytest-asyncio >= 0.17",
@@ -49,7 +49,7 @@ extras_require = {
         "black >= 22.3.0",
         "dnspython >= 2.1",
         "flake8 >= 4.0",
-        "mypy >= 0.981",
+        "mypy >= 0.990",
         "types-setuptools >= 57.4",
         "wheel >= 0.37",
     ],
index 5448777ea25a300f408e50808ffa513280cf2c82..14f3c9e0d4f4ed6ede6b50611d0a81f4b5bb2783 100644 (file)
@@ -34,8 +34,9 @@ files = [
 ]
 warn_unused_ignores = true
 show_error_codes = true
+disable_bytearray_promotion = true
+disable_memoryview_promotion = true
 strict = true
-enable_recursive_aliases = true
 
 [[tool.mypy.overrides]]
 module = [