Skip to content

RUF027 false negative on method calls #9857

@ocaballeror

Description

@ocaballeror

From what I read in the original PR, the rule is meant to ignore string literals that have an immediate method call on them to avoid false positives, but from what I'm seeing, every line with a method call is completely ignored, even if the method is not invoked on the string itself. Is this intended behavior?

Sample code:

import logging


class Test:
    def method(self, arg):
        pass


name = "john"

print("hello {name}")  # correctly fails
logging.info("hello {name}")  # should fail but doesn't
Test().method("hello {name}")  # also should fail but doesn't

Invoked with:

ruff --isolated --select RUF027 --preview thing.py

Ruff version:

ruff 0.2.1

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions