Steve Dignam

Results 76 issues of Steve Dignam

I think this rule could be pretty general but a basic example: ```python # err for id in list({x.bar for x in foo}): ... # ok for id in {x.bar...

enhancement

```python # err not foo == bar # ok foo != bar ```

```python # err class Foo(Base): def __init__(self, *args: Any, **kwargs: Any) -> None: super(Base, self).__init__(*args, **kwargs) # ok class Foo(Base): def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs)...

enhancement

```python # error foo.startswith("foo") or foo.startswith("bar") # ok foo.startswith(("foo", "bar")) # error foo.endswith("foo") or foo.endswith("bar") # ok foo.endswith(("foo", "bar")) ```

enhancement

```python # err redis.set(redis_key, data) redis.expire(redis_key, timedelta(days=1)) # ok redis.set(redis_key, data, ex=timedelta(days=1)) ``` Note: I think we'd want to ignore the name of the client, and look for methods `.set`...

enhancement

```python # err @app.task(name="foo") def foo() -> None: ... # err @shared_task(name="foo") def foo() -> None: ... # ok @app.task(name="foo", ignore_result=True) def foo() -> None: ... # ok @shared_task(name="foo", ignore_result=True)...

enhancement

probably have one for ends with as well, or maybe they can the same rule? ```python # err if re.search(r"^@.*$", foo): ... # ok if foo.startswith("@"): ... ```

enhancement

aka when checking the truthiness of the value, `or` is shorter ```python # err foo if foo else bar foo.buzz if foo.buzz else bar # ok foo.buzz if cond else...

enhancement
tricky

Basically, for things like DB clients, prefer using the `with` API instead of manually calling `close` ```python # err conn = psycopg2.connect(dsn=dsn) cursor = conn.cursor() cursor.execute("SELECT 1") cursor.close() conn.close() #...

enhancement
requires types

```python # 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)...

enhancement