]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
chore: drop redundant brackets
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Wed, 7 May 2025 01:55:12 +0000 (03:55 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Wed, 7 May 2025 18:16:21 +0000 (20:16 +0200)
psycopg/psycopg/_dns.py
psycopg/psycopg/dbapi20.py
psycopg/psycopg/pq/_debug.py
psycopg/psycopg/pq/misc.py
psycopg/psycopg/types/json.py
tests/fix_faker.py
tools/update_oids.py

index 4535b73d2770f2d8691e50a48b7e8043abb3e83a..57cc2595fb88bd6917f1486bf4984eef221ffaf8 100644 (file)
@@ -141,7 +141,7 @@ class Rfc2782Resolver:
         host_arg: str = params.get("host", os.environ.get("PGHOST", ""))
         hosts_in = host_arg.split(",")
         port_arg: str = str(params.get("port", os.environ.get("PGPORT", "")))
-        if len((ports_in := port_arg.split(","))) == 1:
+        if len(ports_in := port_arg.split(",")) == 1:
             # If only one port is specified, it applies to all the hosts.
             ports_in *= len(hosts_in)
         if len(ports_in) != len(hosts_in):
index bffcf327cb23c0df554892d746eb280bba922622..79b870f0c54e9813f82079b490afe9bba17cd6c2 100644 (file)
@@ -72,7 +72,7 @@ class Binary:
         self.obj = obj
 
     def __repr__(self) -> str:
-        if len((sobj := repr(self.obj))) > 40:
+        if len(sobj := repr(self.obj)) > 40:
             sobj = f"{sobj[:35]} ... ({len(sobj)} byteschars)"
         return f"{self.__class__.__name__}({sobj})"
 
index 3efd9a0841f60b780c42b5e2affd560eb53c6e4b..4db4c3a9f9196b7cfc2eff4a8f53055ca72128a4 100644 (file)
@@ -57,7 +57,7 @@ class PGconnDebug:
         return f"<{cls} {info} at 0x{id(self):x}>"
 
     def __getattr__(self, attr: str) -> Any:
-        if callable((value := getattr(self._pgconn, attr))):
+        if callable(value := getattr(self._pgconn, attr)):
             return debugging(value)
         else:
             logger.info("PGconn.%s -> %s", attr, value)
index 354a30ba9245d34f837f58df28c38e98f8db2e4c..fc223163f015b3aa391f212a2c9d59c4f69519e1 100644 (file)
@@ -65,7 +65,7 @@ def find_libpq_full_path() -> str | None:
                 import subprocess as sp
 
                 libdir = sp.check_output(["pg_config", "--libdir"]).strip().decode()
-                if not os.path.exists((libname := os.path.join(libdir, "libpq.dylib"))):
+                if not os.path.exists(libname := os.path.join(libdir, "libpq.dylib")):
                     libname = None
             except Exception as ex:
                 logger.debug("couldn't use pg_config to find libpq: %s", ex)
@@ -169,7 +169,7 @@ def connection_summary(pgconn: abc.PGconn) -> str:
             # before upgrading the ConnStatus enum.
             status = f"status={pgconn.status} (unkndown)"
 
-    if sparts := " ".join(("%s=%s" % part for part in parts)):
+    if sparts := " ".join("%s=%s" % part for part in parts):
         sparts = f" ({sparts})"
     return f"[{status}]{sparts}"
 
index f35dd0a8a255238497715d7d1a567d5fa9a0eb26..d5b6149ccb198041010598603a36eb0d5f5a48f1 100644 (file)
@@ -119,7 +119,7 @@ class _JsonWrapper:
         self.dumps = dumps
 
     def __repr__(self) -> str:
-        if len((sobj := repr(self.obj))) > 40:
+        if len(sobj := repr(self.obj)) > 40:
             sobj = f"{sobj[:35]} ... ({len(sobj)} chars)"
         return f"{self.__class__.__name__}({sobj})"
 
index 05e699ef0d0360abacba00c7fc364f630628a241..70e1d971ccbe0d9b0bb204a62de2ca880fe476f4 100644 (file)
@@ -157,7 +157,7 @@ class Faker:
                     try:
                         cur.execute(self._insert_field_stmt(j), (val,))
                     except psycopg.DatabaseError as e:
-                        if len((r := repr(val))) > 200:
+                        if len(r := repr(val)) > 200:
                             r = f"{r[:200]}... ({len(r)} chars)"
                         raise Exception(
                             f"value {r!r} at record {i} column0 {j} failed insert: {e}"
@@ -181,7 +181,7 @@ class Faker:
                     try:
                         await acur.execute(self._insert_field_stmt(j), (val,))
                     except psycopg.DatabaseError as e:
-                        if len((r := repr(val))) > 200:
+                        if len(r := repr(val)) > 200:
                             r = f"{r[:200]}... ({len(r)} chars)"
                         raise Exception(
                             f"value {r!r} at record {i} column0 {j} failed insert: {e}"
index 51d877734e1d72db226fd856db42b972367549e5..90238d679ccb79d87abd4fb50cf9b282489c4376 100755 (executable)
@@ -35,7 +35,7 @@ ROOT = Path(__file__).parent.parent
 def main() -> None:
     opt = parse_cmdline()
 
-    if CrdbConnection.is_crdb((conn := psycopg.connect(opt.dsn, autocommit=True))):
+    if CrdbConnection.is_crdb(conn := psycopg.connect(opt.dsn, autocommit=True)):
         conn = CrdbConnection.connect(opt.dsn, autocommit=True)
         update_crdb_python_oids(conn)
     else: