Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/pandas/api/typing/__init__.py: 55%

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

31 statements  

1""" 

2Public API classes that store intermediate results useful for type-hinting. 

3""" 

4 

5from typing import TYPE_CHECKING 

6 

7from pandas._libs import NaTType 

8from pandas._libs.lib import NoDefault 

9from pandas._libs.missing import NAType 

10 

11from pandas.core.col import Expression 

12from pandas.core.groupby import ( 

13 DataFrameGroupBy, 

14 SeriesGroupBy, 

15) 

16from pandas.core.indexes.frozen import FrozenList 

17from pandas.core.resample import ( 

18 DatetimeIndexResamplerGroupBy, 

19 PeriodIndexResamplerGroupBy, 

20 Resampler, 

21 TimedeltaIndexResamplerGroupBy, 

22 TimeGrouper, 

23) 

24from pandas.core.window import ( 

25 Expanding, 

26 ExpandingGroupBy, 

27 ExponentialMovingWindow, 

28 ExponentialMovingWindowGroupBy, 

29 Rolling, 

30 RollingGroupBy, 

31 Window, 

32) 

33 

34# TODO: Can't import Styler without importing jinja2 

35# from pandas.io.formats.style import Styler 

36from pandas.io.json._json import JsonReader 

37from pandas.io.sas.sasreader import SASReader 

38from pandas.io.stata import StataReader 

39 

40__all__ = [ 

41 "DataFrameGroupBy", 

42 "DatetimeIndexResamplerGroupBy", 

43 "Expanding", 

44 "ExpandingGroupBy", 

45 "ExponentialMovingWindow", 

46 "ExponentialMovingWindowGroupBy", 

47 "Expression", 

48 "FrozenList", 

49 "JsonReader", 

50 "NAType", 

51 "NaTType", 

52 "NoDefault", 

53 "PeriodIndexResamplerGroupBy", 

54 "Resampler", 

55 "Rolling", 

56 "RollingGroupBy", 

57 "SASReader", 

58 "SeriesGroupBy", 

59 "StataReader", 

60 "TimeGrouper", 

61 "TimedeltaIndexResamplerGroupBy", 

62 "Window", 

63] 

64 

65 

66if TYPE_CHECKING: 

67 # GH#49578 this module exists for type-hinting, so annotating with a 

68 # deprecated spelling has to keep working until it is removed. Binding these 

69 # unconditionally would instead put them back in the public namespace. 

70 DatetimeIndexResamplerGroupby = DatetimeIndexResamplerGroupBy 

71 ExpandingGroupby = ExpandingGroupBy 

72 ExponentialMovingWindowGroupby = ExponentialMovingWindowGroupBy 

73 PeriodIndexResamplerGroupby = PeriodIndexResamplerGroupBy 

74 RollingGroupby = RollingGroupBy 

75 TimedeltaIndexResamplerGroupby = TimedeltaIndexResamplerGroupBy 

76else: 

77 # would otherwise land in the public namespace; see test_api_typing 

78 del TYPE_CHECKING 

79 

80 def __getattr__(name: str) -> object: 

81 deprecated = { 

82 "DatetimeIndexResamplerGroupby": DatetimeIndexResamplerGroupBy, 

83 "ExpandingGroupby": ExpandingGroupBy, 

84 "ExponentialMovingWindowGroupby": ExponentialMovingWindowGroupBy, 

85 "PeriodIndexResamplerGroupby": PeriodIndexResamplerGroupBy, 

86 "RollingGroupby": RollingGroupBy, 

87 "TimedeltaIndexResamplerGroupby": TimedeltaIndexResamplerGroupBy, 

88 } 

89 if name in deprecated: 

90 # imported here rather than at module level, which would expose 

91 # them as pandas.api.typing attributes 

92 import warnings 

93 

94 from pandas.errors import Pandas4Warning 

95 

96 new = deprecated[name] 

97 warnings.warn( 

98 f"pandas.api.typing.{name} is deprecated and will be removed in " 

99 f"a future version. Use pandas.api.typing.{new.__name__} instead.", 

100 Pandas4Warning, 

101 stacklevel=2, 

102 ) 

103 return new 

104 raise AttributeError(f"module 'pandas.api.typing' has no attribute '{name}'")