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

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

11 statements  

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 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 ) 

27 

28 

29@staticmethod 

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

31 raise UnsupportedSubclassing()