Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/referencing/_attrs.py: 100%

10 statements  

« prev     ^ index     » next       coverage.py v7.3.2, created at 2023-12-08 06:51 +0000

1from __future__ import annotations 

2 

3from typing import NoReturn, TypeVar 

4 

5from attrs import define as _define, frozen as _frozen 

6 

7_T = TypeVar("_T") 

8 

9 

10def define(cls: type[_T]) -> type[_T]: # pragma: no cover 

11 cls.__init_subclass__ = _do_not_subclass 

12 return _define(cls) 

13 

14 

15def frozen(cls: type[_T]) -> type[_T]: 

16 cls.__init_subclass__ = _do_not_subclass 

17 return _frozen(cls) 

18 

19 

20class UnsupportedSubclassing(Exception): 

21 pass 

22 

23 

24@staticmethod 

25def _do_not_subclass() -> NoReturn: # pragma: no cover 

26 raise UnsupportedSubclassing( 

27 "Subclassing is not part of referencing's public API. " 

28 "If no other suitable API exists for what you're trying to do, " 

29 "feel free to file an issue asking for one.", 

30 )