Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/werkzeug/datastructures/__init__.py: 63%

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

46 statements  

1from __future__ import annotations 

2 

3import typing as t 

4 

5from .accept import Accept as Accept 

6from .accept import LanguageAccept as LanguageAccept 

7from .accept import MIMEAccept as MIMEAccept 

8from .auth import Authorization as Authorization 

9from .auth import WWWAuthenticate as WWWAuthenticate 

10from .cache_control import RequestCacheControl as RequestCacheControl 

11from .cache_control import ResponseCacheControl as ResponseCacheControl 

12from .csp import ContentSecurityPolicy as ContentSecurityPolicy 

13from .etag import ETag as ETag 

14from .etag import ETagSet as ETagSet 

15from .file_storage import FileMultiDict as FileMultiDict 

16from .file_storage import FileStorage as FileStorage 

17from .headers import EnvironHeaders as EnvironHeaders 

18from .headers import Headers as Headers 

19from .mixins import ImmutableHeadersMixin as ImmutableHeadersMixin 

20from .mixins import ImmutableMultiDictMixin as ImmutableMultiDictMixin 

21from .range import ContentRange as ContentRange 

22from .range import IfRange as IfRange 

23from .range import Range as Range 

24from .set import HeaderSet as HeaderSet 

25from .structures import CallbackDict as CallbackDict 

26from .structures import CombinedMultiDict as CombinedMultiDict 

27from .structures import ImmutableMultiDict as ImmutableMultiDict 

28from .structures import iter_multi_items as iter_multi_items 

29from .structures import MultiDict as MultiDict 

30 

31if not t.TYPE_CHECKING: 

32 

33 def __getattr__(name: str) -> t.Any: 

34 import warnings 

35 

36 if name == "ETags": 

37 warnings.warn( 

38 "'ETags' has been renamed to 'ETagSet'. The old name is deprecated and" 

39 " will be removed in Werkzeug 4.0.", 

40 DeprecationWarning, 

41 stacklevel=2, 

42 ) 

43 return ETagSet 

44 

45 if name == "CharsetAccept": 

46 from .accept import _CharsetAccept 

47 

48 warnings.warn( 

49 "The 'CharsetAccept' class is deprecated and will be removed in" 

50 " Werkzeug 4.0. The 'Accept-Charset' header is not sent by" 

51 " browsers, and UTF-8 is assumed.", 

52 DeprecationWarning, 

53 stacklevel=2, 

54 ) 

55 return _CharsetAccept 

56 

57 from . import mixins 

58 from . import structures 

59 

60 alts = { 

61 "ImmutableListMixin": (mixins, "collections.abc.Sequence"), 

62 "ImmutableList": (structures, "collections.abc.Sequence"), 

63 "ImmutableDictMixin": (mixins, "collections.abc.Mapping"), 

64 "ImmutableDict": (structures, "collections.abc.Mapping"), 

65 "UpdateDictMixin": (mixins, "CallbackDict"), 

66 "ImmutableTypeConversionDict": (structures, "ImmutableMultiDict"), 

67 "TypeConversionDict": (structures, "MultiDict"), 

68 } 

69 

70 if name in alts: 

71 import warnings 

72 

73 mod, alt = alts[name] 

74 warnings.warn( 

75 f"The '{name}' class is deprecated and will be removed in" 

76 f" Werkzeug 4.0. Use '{alt}' instead.", 

77 DeprecationWarning, 

78 stacklevel=2, 

79 ) 

80 return getattr(mod, f"_{name}") 

81 

82 raise AttributeError(name)