Coverage for typed_stream / _impl / _typing.py: 85%

13 statements  

« prev     ^ index     » next       coverage.py v7.13.4, created at 2026-03-17 08:56 +0000

1# Licensed under the EUPL-1.2 or later. 

2# You may obtain a copy of the licence in all the official languages of the 

3# European Union at https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12 

4 

5"""Provide types.""" 

6 

7from __future__ import annotations 

8 

9import typing 

10 

11if typing.TYPE_CHECKING: # noqa: C901 # pragma: no cover 

12 import sys 

13 

14 if sys.version_info < (3, 11): 

15 from typing_extensions import ( 

16 Self, 

17 TypeVarTuple, 

18 Unpack, 

19 assert_never, 

20 assert_type, 

21 ) 

22 else: 

23 from typing import Self, TypeVarTuple, Unpack, assert_never, assert_type 

24 

25 if sys.version_info < (3, 12): 

26 from typing_extensions import override 

27 else: 

28 from typing import override 

29else: 

30 

31 def return_arg(arg: object, *_) -> object: 

32 """Return the argument.""" 

33 return arg 

34 

35 def assert_never(arg: object, /) -> typing.Never: 

36 """Never call this.""" 

37 raise AssertionError(f"{arg} was not never") 

38 

39 # pylint: disable=invalid-name 

40 Self = getattr(typing, "Self", ...) 

41 TypeVarTuple = getattr(typing, "TypeVarTuple", return_arg) 

42 Unpack = getattr(typing, "Unpack", ...) 

43 override = getattr(typing, "override", return_arg) 

44 assert_type = getattr(typing, "assert_type", return_arg) 

45 assert_never = getattr(typing, "assert_never", assert_never) 

46 

47__all__ = ( 

48 "Self", 

49 "TypeVarTuple", 

50 "Unpack", 

51 "override", 

52 "assert_type", 

53 "assert_never", 

54)