From 615054392a18ae5c9c82e845ddaa107f03f160b8 Mon Sep 17 00:00:00 2001 From: Oliver Bestwalter Date: Mon, 17 Jun 2019 09:17:29 +0200 Subject: [PATCH] Rename remaining validator/default decorator examples with unclear names (#544) The documentation already explains well why validator or default decorated methods must not have the name of existing attributes (because they would be overridden). This replaces the last remaining examples not using the explicit explanatory name. --- docs/api.rst | 4 ++-- docs/examples.rst | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index 98ea8459..c6cd1053 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -73,11 +73,11 @@ Core ... x = attr.ib() ... y = attr.ib() ... @x.validator - ... def name_can_be_anything(self, attribute, value): + ... def _any_name_except_a_name_of_an_attribute(self, attribute, value): ... if value < 0: ... raise ValueError("x must be positive") ... @y.default - ... def name_does_not_matter(self): + ... def _any_name_except_a_name_of_an_attribute(self): ... return self.x + 1 >>> C(1) C(x=1, y=2) diff --git a/docs/examples.rst b/docs/examples.rst index b54637eb..fad5c263 100644 --- a/docs/examples.rst +++ b/docs/examples.rst @@ -341,7 +341,7 @@ The method receives the partially initialized instance which enables you to base ... x = attr.ib(default=1) ... y = attr.ib() ... @y.default - ... def name_does_not_matter(self): + ... def _any_name_except_a_name_of_an_attribute(self): ... return self.x + 1 >>> C() C(x=1, y=2)