Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prefer-collapsed-with #88

Open
sbdchd opened this issue Jun 12, 2021 · 1 comment
Open

prefer-collapsed-with #88

sbdchd opened this issue Jun 12, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@sbdchd
Copy link
Owner

sbdchd commented Jun 12, 2021

# 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 sbdchd added the enhancement New feature or request label Jun 13, 2021
@Skylion007
Copy link

Partially implemented as SIM117 in flake8-simplify

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants