Set the value of this option Raises a ``TypeError`` if this option is not :attr:`Option.mutable`.
(self, new: Any)
| 86 | return hasattr(self, "_current") |
| 87 | |
| 88 | def set_current(self, new: Any) -> None: |
| 89 | """Set the value of this option |
| 90 | |
| 91 | Raises a ``TypeError`` if this option is not :attr:`Option.mutable`. |
| 92 | """ |
| 93 | old = self.current |
| 94 | if new is old: |
| 95 | return None |
| 96 | |
| 97 | if not self._mutable: |
| 98 | msg = f"{self} cannot be modified after initial load" |
| 99 | raise TypeError(msg) |
| 100 | |
| 101 | try: |
| 102 | new = self._current = self._validator(new) |
| 103 | except ValueError as error: |
| 104 | raise ValueError(f"Invalid value for {self._name}: {new!r}") from error |
| 105 | |
| 106 | logger.debug(f"{self._name}={self._current}") |
| 107 | if new != old: |
| 108 | for sub_func in self._subscribers: |
| 109 | sub_func(new) |
| 110 | |
| 111 | def set_default(self, new: _O) -> _O: |
| 112 | """Set the value of this option if not :meth:`Option.is_set` |
no outgoing calls
no test coverage detected