hdl.ast: formatting. NFC.

This commit is contained in:
whitequark 2020-12-12 14:11:40 +00:00
parent 818c8bc464
commit 7dde2aac7c

View file

@ -1290,19 +1290,20 @@ class ValueCastable:
Note that it is necessary to ensure that nMigen's view of representation of all values stays Note that it is necessary to ensure that nMigen's view of representation of all values stays
internally consistent. The class deriving from ``ValueCastable`` must decorate the ``as_value`` internally consistent. The class deriving from ``ValueCastable`` must decorate the ``as_value``
method with the ``lowermethod`` decorator, which ensures that all calls to ``as_value``return the method with the ``lowermethod`` decorator, which ensures that all calls to ``as_value`` return
same ``Value`` representation. If the class deriving from ``ValueCastable`` is mutable, it is the same ``Value`` representation. If the class deriving from ``ValueCastable`` is mutable,
up to the user to ensure that it is not mutated in a way that changes its representation after it is up to the user to ensure that it is not mutated in a way that changes its representation
the first call to ``as_value``. after the first call to ``as_value``.
""" """
def __new__(cls, *args, **kwargs): def __new__(cls, *args, **kwargs):
self = super().__new__(cls) self = super().__new__(cls)
if not hasattr(self, "as_value"): if not hasattr(self, "as_value"):
raise TypeError(f"Class '{cls.__name__}' deriving from `ValueCastable` must override the `as_value` method") raise TypeError(f"Class '{cls.__name__}' deriving from `ValueCastable` must override "
"the `as_value` method")
if not hasattr(self.as_value, "_ValueCastable__memoized"): if not hasattr(self.as_value, "_ValueCastable__memoized"):
raise TypeError(f"Class '{cls.__name__}' deriving from `ValueCastable` must decorate the `as_value` " raise TypeError(f"Class '{cls.__name__}' deriving from `ValueCastable` must decorate "
"method with the `ValueCastable.lowermethod` decorator") "the `as_value` method with the `ValueCastable.lowermethod` decorator")
return self return self
@staticmethod @staticmethod