Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/referencing/_attrs.py: 91%
11 statements
« prev ^ index » next coverage.py v7.4.0, created at 2024-01-22 06:29 +0000
« prev ^ index » next coverage.py v7.4.0, created at 2024-01-22 06:29 +0000
1from __future__ import annotations
3from typing import NoReturn, TypeVar
5from attrs import define as _define, frozen as _frozen
7_T = TypeVar("_T")
10def define(cls: type[_T]) -> type[_T]: # pragma: no cover
11 cls.__init_subclass__ = _do_not_subclass
12 return _define(cls)
15def frozen(cls: type[_T]) -> type[_T]:
16 cls.__init_subclass__ = _do_not_subclass
17 return _frozen(cls)
20class UnsupportedSubclassing(Exception):
21 def __str__(self):
22 return (
23 "Subclassing is not part of referencing's public API. "
24 "If no other suitable API exists for what you're trying to do, "
25 "feel free to file an issue asking for one."
26 )
29@staticmethod
30def _do_not_subclass() -> NoReturn: # pragma: no cover
31 raise UnsupportedSubclassing()