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.
I don' think that
WPS222should count nested conditions, only top level ones.It has 3 top level condtions, no error should be raised.