Skip to content

FBT003 with Pydantic #10485

@redb0

Description

@redb0

Hello!

I use Ruff version 0.1.15 with flake8-boolean-trap. I am getting this error in the following example:

from pydantic import Field
from pydantic_settings import BaseSettings


class Settings(BaseSettings):

    foo: bool = Field(True, exclude=True)

Command ruff test.py --fix return

test.py:7:23: FBT003 Boolean positional value in function call

Pydantic allows you to explicitly specify the default parameter (foo: bool = Field(default=True, ...)). However, this stands out from the general code, where other values ​​are specified without it.

I’m not sure that it’s worth “strictly” filtering such cases. On the one hand, I can disable this check for certain files. I think it's not right to do this. Maybe it’s worth allowing the user to independently specify filtering rules, in addition to those initially specified as here https://github.com/astral-sh/ruff/blob/main/crates/ruff_linter/src/rules/flake8_boolean_trap/helpers.rs#L7?

I'd be glad to hear your opinion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    configurationRelated to settings and configurationruleImplementing 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