The adaptions to B902 cause a regression when using the attrs library:
import attrs
from typing import Any
@attrs.frozen
class SpamAndEggs:
foobar: list[int] = attrs.field()
@foobar.validator
def _positive(
self,
attribute: "attrs.Attribute[list[int]]",
value: Any,
) -> None:
if any(i < 0 for i in value):
raise ValueError()
SpamAndEggs([1, 2, 3])
The error is:
myfile.py:11:9: B902 Invalid first argument 'self' used for class method. Use the canonical first argument name in methods, i.e. cls.
My suggestion would be to remove validator and root_validator from the default list and allow pydantic user to set them via the commandline flag. I would imagine that other libraries also have @validator decorators or that some people write their own
The adaptions to B902 cause a regression when using the attrs library:
The error is:
My suggestion would be to remove validator and root_validator from the default list and allow pydantic user to set them via the commandline flag. I would imagine that other libraries also have @validator decorators or that some people write their own