From: Daniele Varrazzo Date: Thu, 3 Nov 2022 23:16:10 +0000 (+0100) Subject: chore: bump mypy to 0.990 X-Git-Tag: 3.1.5~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f12f5f37f3e623b7d4fbe7f0482970bccdcd1cc3;p=thirdparty%2Fpsycopg.git chore: bump mypy to 0.990 --- diff --git a/psycopg/psycopg/copy.py b/psycopg/psycopg/copy.py index 1313a9a71..274b20083 100644 --- a/psycopg/psycopg/copy.py +++ b/psycopg/psycopg/copy.py @@ -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) diff --git a/psycopg/psycopg/pq/misc.py b/psycopg/psycopg/pq/misc.py index d3da88cad..3a43133ce 100644 --- a/psycopg/psycopg/pq/misc.py +++ b/psycopg/psycopg/pq/misc.py @@ -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 diff --git a/psycopg/psycopg/pq/pq_ctypes.py b/psycopg/psycopg/pq/pq_ctypes.py index 51462fea8..8b87c19f4 100644 --- a/psycopg/psycopg/pq/pq_ctypes.py +++ b/psycopg/psycopg/pq/pq_ctypes.py @@ -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 ) ) diff --git a/psycopg/psycopg/types/enum.py b/psycopg/psycopg/types/enum.py index 94d833739..3e195443d 100644 --- a/psycopg/psycopg/types/enum.py +++ b/psycopg/psycopg/types/enum.py @@ -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}" ) diff --git a/psycopg/psycopg/types/net.py b/psycopg/psycopg/types/net.py index 1fdad84fc..b07cfb696 100644 --- a/psycopg/psycopg/types/net.py +++ b/psycopg/psycopg/types/net.py @@ -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 diff --git a/psycopg/psycopg/types/uuid.py b/psycopg/psycopg/types/uuid.py index 9cacef6d6..f92354c35 100644 --- a/psycopg/psycopg/types/uuid.py +++ b/psycopg/psycopg/types/uuid.py @@ -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": diff --git a/psycopg/setup.py b/psycopg/setup.py index fb041efd1..edb2b3501 100644 --- a/psycopg/setup.py +++ b/psycopg/setup.py @@ -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", ], diff --git a/pyproject.toml b/pyproject.toml index 5448777ea..14f3c9e0d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 = [