MCPcopy
hub / github.com/pydata/xarray / __init_subclass__

Method __init_subclass__

xarray/core/common.py:271–287  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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]]:

Callers

nothing calls this directly

Calls 2

startswithMethod · 0.80
__new__Method · 0.45

Tested by

no test coverage detected