Raymond Hettinger posted a helpful example to this list. Here, I run
his example, and a variant, through https://black.now.sh
Raymond
class Frabawidget:
@wozzle.setter
def wibble(self, woozle):
if not (self.min_woozle < woozle < self.max_woozle):
raise ValueError(f"Expected woozle to be between
{self.min_woozle} and {self.max_woozle}")
self._wozzle = normalize(woozle)
black.py
class Frabawidget:
@wozzle.setter
def wibble(self, woozle):
if not (self.min_woozle < woozle < self.max_woozle):
raise ValueError(
f"Expected woozle to be between {self.min_woozle} and
{self.max_woozle}"
)
self._wozzle = normalize(woozle)
Raymond variant
class Frabawidget:
@wozzle.setter
def wibble(self, woozle):
if not (self.min_woozle < woozle < self.max_woozle <
self.super_max_value) and do_this_or_that_():
raise ValueError(f"Expected woozle to be between
{self.min_woozle} and {self.max_woozle}")
self._wozzle = normalize(woozle)
black.py
class Frabawidget:
@wozzle.setter
def wibble(self, woozle):
if (
not (
self.min_woozle
< woozle
< self.max_woozle
< self.super_max_value
)
and do_this_or_that_()
):
raise ValueError(
f"Expected woozle to be between {self.min_woozle} and
{self.max_woozle}"
)
self._wozzle = normalize(woozle)
(By the way, I had to add the 'wibble' to the code above, to avoid a
syntax error.)
--
Jonathan
_______________________________________________
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/