diff --git a/funkwhale_network/cli.py b/funkwhale_network/cli.py index 9c62da5b2da621faf8064dc72177376057a9b693..0f93f002f2b599ab0918e89585f862d172d08aee 100644 --- a/funkwhale_network/cli.py +++ b/funkwhale_network/cli.py @@ -153,7 +153,6 @@ async def crawl(domain, use_public, detail, passes, sort): aggregate = aggregate_crawl_results(results["results"]) if detail != NOOP: - click.echo("") click.echo("Info per domain") click.echo("===============") diff --git a/funkwhale_network/db.py b/funkwhale_network/db.py index 5fc301d1291acf5d29376f9627ed643dd5bd463b..088844cc85e8cee3afd89cba10063f947b828788 100644 --- a/funkwhale_network/db.py +++ b/funkwhale_network/db.py @@ -36,7 +36,7 @@ class DB: yield self.pool.cursor() async def create_domains_table(self): - with (await self.pool.cursor()) as cursor: + with await self.pool.cursor() as cursor: await cursor.execute( """ CREATE TABLE IF NOT EXISTS domains ( @@ -77,7 +77,7 @@ class DB: ALTER TABLE checks ADD COLUMN IF NOT EXISTS usage_downloads_total INTEGER NULL; SELECT create_hypertable('checks', 'time', if_not_exists => TRUE); """ - with (await self.pool.cursor()) as cursor: + with await self.pool.cursor() as cursor: await cursor.execute(sql) cursor.close() @@ -86,7 +86,7 @@ class DB: await create_handler() async def clear(self): - with (await self.pool.cursor()) as cursor: + with await self.pool.cursor() as cursor: for table, _ in self.TABLES: await cursor.execute(f"DROP TABLE IF EXISTS {table} CASCADE") @@ -98,8 +98,8 @@ class DB: WHERE private = %s AND domains.blocked = false ORDER BY domain, time DESC """ - with ( - await self.pool.cursor(cursor_factory=psycopg2.extras.RealDictCursor) + with await self.pool.cursor( + cursor_factory=psycopg2.extras.RealDictCursor ) as cursor: await cursor.execute(sql, [False]) return list(await cursor.fetchall()) @@ -165,16 +165,16 @@ class DB: return base_query.format(where_clause=""), [] async def get_all_domains(self): - with ( - await self.pool.cursor(cursor_factory=psycopg2.extras.RealDictCursor) + with await self.pool.cursor( + cursor_factory=psycopg2.extras.RealDictCursor ) as cursor: await cursor.execute("SELECT name FROM domains") domains = list(await cursor.fetchall()) return domains async def get_domains(self, **kwargs): - with ( - await self.pool.cursor(cursor_factory=psycopg2.extras.RealDictCursor) + with await self.pool.cursor( + cursor_factory=psycopg2.extras.RealDictCursor ) as cursor: filters = kwargs.copy() filters.setdefault("private", False) @@ -209,15 +209,15 @@ class DB: return True async def get_domain(self, name): - with ( - await self.pool.cursor(cursor_factory=psycopg2.extras.RealDictCursor) + with await self.pool.cursor( + cursor_factory=psycopg2.extras.RealDictCursor ) as cursor: await cursor.execute("SELECT * FROM domains WHERE name = %s", (name,)) return list(await cursor.fetchall())[0] async def save_check(self, data): - with ( - await self.pool.cursor(cursor_factory=psycopg2.extras.RealDictCursor) + with await self.pool.cursor( + cursor_factory=psycopg2.extras.RealDictCursor ) as cursor: node_name = data.pop("node_name", None) fields, values = [], [] @@ -245,8 +245,8 @@ class DB: return check async def create_domain(self, data): - with ( - await self.pool.cursor(cursor_factory=psycopg2.extras.RealDictCursor) + with await self.pool.cursor( + cursor_factory=psycopg2.extras.RealDictCursor ) as cursor: sql = "INSERT INTO domains (name) VALUES (%s) ON CONFLICT DO NOTHING RETURNING *" await cursor.execute(sql, [data["name"]]) diff --git a/funkwhale_network/output.py b/funkwhale_network/output.py index 8deecb4ea1d5e6ef1cac11d833ffd18a217cffe9..f470def72d282b45ca8288f109b5645328a5b4b2 100644 --- a/funkwhale_network/output.py +++ b/funkwhale_network/output.py @@ -51,7 +51,6 @@ def get_value(obj, config, truncate=30): def table(objects, fields, type, headers=True, format="simple", sort=None): - configs = {} if sort: diff --git a/tests/test_db.py b/tests/test_db.py index 8b8cb887861d4747fb94210b98b6ff531954b10a..52362da44ad58d6279ce95173f88de30fda25df5 100644 --- a/tests/test_db.py +++ b/tests/test_db.py @@ -14,7 +14,6 @@ async def test_create_domain_ignore_duplicate(populated_db): async def test_db_create(): - async with DB() as db: try: await db.create()