flake8-pie icon indicating copy to clipboard operation
flake8-pie copied to clipboard

prefer-collapsed-with

Open sbdchd opened this issue 4 years ago • 1 comments

# err
with psycopg2.connect(dsn=dsn) as conn:
    with conn.cursor() as cursor:
        cursor.execute("SELECT 1")

# ok
with psycopg2.connect(dsn=dsn) as conn, conn.cursor() as cursor:
    cursor.execute("SELECT 1")

# err
async with asyncpg.create_pool(user="postgres", command_timeout=60) as pool:
    async with pool.acquire() as con:
        await con.execute(
            """
           CREATE TABLE names (
              id serial PRIMARY KEY,
              name VARCHAR (255) NOT NULL)
        """
        )
        await con.fetch("SELECT 1")


# ok
async with asyncpg.create_pool(
    user="postgres", command_timeout=60
) as pool, pool.acquire() as con:
    await con.execute(
        """
           CREATE TABLE names (
              id serial PRIMARY KEY,
              name VARCHAR (255) NOT NULL)
        """
    )
    await con.fetch("SELECT 1")

sbdchd avatar Jun 12 '21 15:06 sbdchd

Partially implemented as SIM117 in flake8-simplify

Skylion007 avatar Feb 21 '23 18:02 Skylion007