Verify that all subclasses explicitly define ``__slots__``. If they don't, raise error in the core xarray module and a FutureWarning in third-party extensions.
(cls, **kwargs)
| 269 | __slots__ = () |
| 270 | |
| 271 | def __init_subclass__(cls, **kwargs): |
| 272 | """Verify that all subclasses explicitly define ``__slots__``. If they don't, |
| 273 | raise error in the core xarray module and a FutureWarning in third-party |
| 274 | extensions. |
| 275 | """ |
| 276 | if not hasattr(object.__new__(cls), "__dict__"): |
| 277 | pass |
| 278 | elif cls.__module__.startswith("xarray."): |
| 279 | raise AttributeError(f"{cls.__name__} must explicitly define __slots__") |
| 280 | else: |
| 281 | cls.__setattr__ = cls._setattr_dict |
| 282 | warnings.warn( |
| 283 | f"xarray subclass {cls.__name__} should explicitly define __slots__", |
| 284 | FutureWarning, |
| 285 | stacklevel=2, |
| 286 | ) |
| 287 | super().__init_subclass__(**kwargs) |
| 288 | |
| 289 | @property |
| 290 | def _attr_sources(self) -> Iterable[Mapping[Hashable, Any]]: |
nothing calls this directly
no test coverage detected