Skip to content

SLF001 rejects acceptable private and protected access #2893

@sanmai-NL

Description

@sanmai-NL

In the following case, a static method is called from within the class definition.
That should be allowed, and from subclasses too.

Calls to private methods should also be allowed from within the class definition.

class TestSLF001:
    @staticmethod
    def _protected() -> None:
        pass

    def public() -> None:
        TestSLF001._protected()
ruff check --select ALL --ignore D103,TCH003,D testslf001.py

ruff 0.0.245

pyproject.toml snippet:

[tool.ruff]
select = ["ALL"]
line-length = 120
target-version = "py311"

Metadata

Metadata

Assignees

No one assigned

    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