Skip to content

RUF027 False positive for non-runtime context binding #14000

Closed
@Daverball

Description

@Daverball

This might be incredibly easy to fix depending on how this check is implemented. Currently RUF027 can be triggered by something like:

from typing import TYPE_CHECKING
if TYPE_CHECKING:
    from datetime import date

path = "foo/{date}/"  # RUF027

Now, to be fair, this would also be a false positive for a runtime binding. But this seems like an easy low hanging fruit to reduce the false positive rate at least a little bit.

Although a more reliable solution long-term would be to add a setting for specifying additional methods which expect a template string.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ruleImplementing 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