Skip to content

WPS222 false positive #3630

@sobolevn

Description

@sobolevn
def func(
    endpoint: 'Endpoint',
    controller: 'Controller[BaseSerializer]',
) -> str | None:
    """Return ``request.user.pk`` when user should be throttled."""
    user = controller.request.user
    user_pk = getattr(user, 'pk', None)
    if (  # TODO: this is a bug in `WPS` :(
        user_pk is None  # noqa: WPS222
        or (getattr(user, 'is_superuser', False) and self.exclude_superuser)
        or (getattr(user, 'is_staff', False) and self.exclude_stuff)
    ):
        return None
    return str(user_pk)

I don' think that WPS222 should count nested conditions, only top level ones.
It has 3 top level condtions, no error should be raised.

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