Skip to content

PTH123 shadows ASYNC101 and SIM115 #6892

@Olegt0rr

Description

@Olegt0rr

Let's ruff:

async def foo() -> None:
    """Open something."""
    open("foo")

Result:

ASYNC101 Async functions should not call `open`, `time.sleep`, or `subprocess` methods
SIM115 Use context handler for opening files
PTH123 `open()` should be replaced by `Path.open()`

Let's apply fix for PTH123 and ruff it again:

async def foo() -> None:
    """Open something."""
    path = Path("foo")
    path.open("foo")

Result: success

Expected:

  • ASYNC101 (cause path.open is also blocking as open for async.)
  • SIM115 (cause path.open works the same as open)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingruleImplementing or modifying a lint rule

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions