As suggested by pyupgrade --py38-plus.
# More than one type in the list. It might be still good, as long
# as they dump with the same oid (e.g. IPv4Network, IPv6Network).
dumpers = [self._tx.get_dumper(item, format) for item in types.values()]
- oids = set(d.oid for d in dumpers)
+ oids = {d.oid for d in dumpers}
if len(oids) == 1:
t, v = types.popitem()
else:
sql = "SELECT * FROM test_table"
if isinstance(conn, psycopg.Connection):
rows = conn.cursor().execute(sql).fetchall()
- return set(v for (v,) in rows)
+ return {v for (v,) in rows}
else:
async def f():
cur = conn.cursor()
await cur.execute(sql)
rows = await cur.fetchall()
- return set(v for (v,) in rows)
+ return {v for (v,) in rows}
return f()
counts[id(conn)] += 1
assert len(counts) == 4
- assert set(counts.values()) == set([2])
+ assert set(counts.values()) == {2}
@pytest.mark.slow
pid = conn.info.backend_pid
p.wait(1.0)
- pids = set((conn.info.backend_pid for conn in p._pool))
+ pids = {conn.info.backend_pid for conn in p._pool}
assert pid in pids
conn.close()
p.check()
assert len(caplog.records) == 1
p.wait(1.0)
- pids2 = set((conn.info.backend_pid for conn in p._pool))
+ pids2 = {conn.info.backend_pid for conn in p._pool}
assert len(pids & pids2) == 3
assert pid not in pids2
counts[id(conn)] += 1
assert len(counts) == 4
- assert set(counts.values()) == set([2])
+ assert set(counts.values()) == {2}
@pytest.mark.slow
pid = conn.info.backend_pid
await p.wait(1.0)
- pids = set(conn.info.backend_pid for conn in p._pool)
+ pids = {conn.info.backend_pid for conn in p._pool}
assert pid in pids
await conn.close()
await p.check()
assert len(caplog.records) == 1
await p.wait(1.0)
- pids2 = set(conn.info.backend_pid for conn in p._pool)
+ pids2 = {conn.info.backend_pid for conn in p._pool}
assert len(pids & pids2) == 3
assert pid not in pids2
for got, want in zip(times, want_times):
assert got == pytest.approx(want, 0.2), times
- assert len(set((r[2] for r in results))) == 2, results
+ assert len({r[2] for r in results}) == 2, results
@pytest.mark.slow
gather(*ts)
sleep(0.2)
- assert set(results) == set([0, 1, 3, 4])
+ assert set(results) == {0, 1, 3, 4}
if pool_cls is pool.ConnectionPool:
assert len(p._pool) == 2 # no connection was lost
for got, want in zip(times, want_times):
assert got == pytest.approx(want, 0.2), times
- assert len(set(r[2] for r in results)) == 2, results
+ assert len({r[2] for r in results}) == 2, results
@pytest.mark.slow
await gather(*ts)
await asleep(0.2)
- assert set(results) == set([0, 1, 3, 4])
+ assert set(results) == {0, 1, 3, 4}
if pool_cls is pool.AsyncConnectionPool:
assert len(p._pool) == 2 # no connection was lost
if not maybe_conv:
logger.error("no file to check? Maybe this script bitrot?")
return 1
- unk_conv = sorted(
- set(maybe_conv) - set(fn.replace("_async", "") for fn in ALL_INPUTS)
- )
+ unk_conv = sorted(set(maybe_conv) - {fn.replace("_async", "") for fn in ALL_INPUTS})
if unk_conv:
logger.error(
"files converted by %s but not included in ALL_INPUTS: %s",
@cached_property
def current_version(self) -> Version:
- versions = set(self._parse_version_from_file(f) for f in self.package.ini_files)
+ versions = {self._parse_version_from_file(f) for f in self.package.ini_files}
if len(versions) > 1:
raise ValueError(
f"inconsistent versions ({', '.join(map(str, sorted(versions)))})"