Skip to content

False positive A003 when overriding logging.Filter.filter #6057

@scur-iolus

Description

@scur-iolus

It's probably a quite common case to use a custom logging.Filter, either to add context to log records or to decide if a given Record is to be logged (cf. Python documentation).

However, Ruff currently considers it breaks the A003 rule:

Class attribute `filter` is shadowing a Python builtinRuff [A003](https://beta.ruff.rs/docs/rules/builtin-attribute-shadowing)

This issue seems to be somewhat related to #5956 and I'm aware that it's probably low-priority.

Here's a minimal reproducible example of the problem:

from logging import Filter, LogRecord

class CustomFilter(Filter):
    def filter(self, record: LogRecord) -> bool:  # noqa: A003 is required here
        return super().filter(self, record)

I'm using ruff 0.0.280.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions