]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
refactor: replace list comprehension with generators in multiple assignments 981/head
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sat, 28 Dec 2024 00:28:30 +0000 (01:28 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sat, 28 Dec 2024 00:47:41 +0000 (01:47 +0100)
tests/pool/test_pool.py
tests/pool/test_pool_async.py
tests/pool/test_pool_null.py
tests/pool/test_pool_null_async.py
tests/test_typing.py
tools/update_error_prefixes.py
tools/update_errors.py
tools/update_oids.py

index a3e991d1fb4671b6938ff4e40ddae790ac02e5ab..d92859cb7490ed1c4c3e4795ee2b05e21ce344e5 100644 (file)
@@ -6,7 +6,7 @@ from __future__ import annotations
 import logging
 import weakref
 from time import time
-from typing import Any, Dict
+from typing import Any
 
 import pytest
 
@@ -43,7 +43,7 @@ def test_bad_size(dsn, min_size, max_size):
         pool.ConnectionPool(min_size=min_size, max_size=max_size)
 
 
-class MyRow(Dict[str, Any]):
+class MyRow(dict[str, Any]):
     pass
 
 
index bdcedff4949883e6b81aeeecb333b660930031d4..464e22ba663ba6595bd05fc534b50e5dda828fb9 100644 (file)
@@ -3,7 +3,7 @@ from __future__ import annotations
 import logging
 import weakref
 from time import time
-from typing import Any, Dict
+from typing import Any
 
 import pytest
 
@@ -43,7 +43,7 @@ async def test_bad_size(dsn, min_size, max_size):
         pool.AsyncConnectionPool(min_size=min_size, max_size=max_size)
 
 
-class MyRow(Dict[str, Any]):
+class MyRow(dict[str, Any]):
     pass
 
 
index 89b39d7af36e6d410003dd1b2fb10e2881c8db29..13260ad0d6776bec338d8fdafd6a8648fb019e4a 100644 (file)
@@ -4,7 +4,7 @@
 from __future__ import annotations
 
 import logging
-from typing import Any, Dict
+from typing import Any
 
 import pytest
 from packaging.version import parse as ver  # noqa: F401  # used in skipif
@@ -41,7 +41,7 @@ def test_bad_size(dsn, min_size, max_size):
         pool.NullConnectionPool(min_size=min_size, max_size=max_size)
 
 
-class MyRow(Dict[str, Any]):
+class MyRow(dict[str, Any]):
     pass
 
 
index c74acb8fdfd5201179294ad8108d3b0588f3206a..c35cacba3c072c83c7c8c0d7f2f34c2e5724245d 100644 (file)
@@ -1,7 +1,7 @@
 from __future__ import annotations
 
 import logging
-from typing import Any, Dict
+from typing import Any
 
 import pytest
 from packaging.version import parse as ver  # noqa: F401  # used in skipif
@@ -41,7 +41,7 @@ async def test_bad_size(dsn, min_size, max_size):
         pool.AsyncNullConnectionPool(min_size=min_size, max_size=max_size)
 
 
-class MyRow(Dict[str, Any]):
+class MyRow(dict[str, Any]):
     pass
 
 
index 2ad397189fdb988eb7884b9ed25df59bc5f9f744..911fca1f9fa84d90616249e26e7bf4deb418b402 100644 (file)
@@ -408,7 +408,7 @@ reveal_type(ref)
     cp = mypy.run_on_source(src)
     out = cp.stdout.decode("utf8", "replace").splitlines()
     assert len(out) == 2, "\n".join(out)
-    got, want = [mypy.get_revealed(line) for line in out]
+    got, want = (mypy.get_revealed(line) for line in out)
     assert got == want
 
 
@@ -447,5 +447,5 @@ reveal_type(ref)
     cp = mypy.run_on_source(src)
     out = cp.stdout.decode("utf8", "replace").splitlines()
     assert len(out) == 2, "\n".join(out)
-    got, want = [mypy.get_revealed(line) for line in out]
+    got, want = (mypy.get_revealed(line) for line in out)
     assert got == want
index af63ae2409c7553d946fd75e3c2344b926272389..9b490880678d0e948171f44040d1ca4aa82be340 100755 (executable)
@@ -49,14 +49,14 @@ def make_regexp(pgroot: Path) -> str:
 def update_file(fn: Path, content: str) -> None:
     logger.info("updating %s", fn)
 
-    with open(fn, "r") as f:
+    with open(fn) as f:
         lines = f.read().splitlines()
 
-    istart, iend = [
+    istart, iend = (
         i
         for i, line in enumerate(lines)
         if re.match(r"\s*(#|\.\.)\s*autogenerated:\s+(start|end)", line)
-    ]
+    )
 
     lines[istart + 1 : iend] = [content]
 
index 3218ccac57c1cd935d3a5d54a581c546c5c1299f..d192aeb10522a3ff310d3b63df58a5eee37b28cd 100755 (executable)
@@ -197,14 +197,14 @@ def generate_docs_data(classes, errors):
 def update_file(fn, new_lines):
     logger.info("updating %s", fn)
 
-    with open(fn, "r") as f:
+    with open(fn) as f:
         lines = f.read().splitlines()
 
-    istart, iend = [
+    istart, iend = (
         i
         for i, line in enumerate(lines)
         if re.match(r"\s*(#|\.\.)\s*autogenerated:\s+(start|end)", line)
-    ]
+    )
 
     lines[istart + 1 : iend] = new_lines
 
index 096cbe9d57102434ea40182f3bef52521f8a803d..fc913e07ff664e52eeb196f46c9058e225c22537 100755 (executable)
@@ -241,11 +241,11 @@ order by typname
 def update_file(fn: Path, new: list[str]) -> None:
     with fn.open("r") as f:
         lines = f.read().splitlines()
-    istart, iend = [
+    istart, iend = (
         i
         for i, line in enumerate(lines)
         if re.match(r"\s*#\s*autogenerated:\s+(start|end)", line)
-    ]
+    )
     lines[istart + 1 : iend] = new + [""]
 
     with fn.open("w") as f: