4
4
import logging
5
5
import warnings
6
6
from copy import deepcopy
7
- from typing import TYPE_CHECKING , Any , Callable , Mapping , Sequence , overload
7
+ from typing import TYPE_CHECKING , Any , Callable , Mapping , Sequence
8
8
9
9
from jsonpath_ng .ext import parse
10
10
@@ -66,6 +66,10 @@ def encrypt(
66
66
fields = None ,
67
67
action = self .provider .encrypt ,
68
68
provider_options = provider_options or {},
69
+ dynamic_mask = None ,
70
+ custom_mask = None ,
71
+ regex_pattern = None ,
72
+ mask_format = None ,
69
73
** encryption_context ,
70
74
)
71
75
@@ -80,47 +84,25 @@ def decrypt(
80
84
fields = None ,
81
85
action = self .provider .decrypt ,
82
86
provider_options = provider_options or {},
87
+ dynamic_mask = None ,
88
+ custom_mask = None ,
89
+ regex_pattern = None ,
90
+ mask_format = None ,
83
91
** encryption_context ,
84
92
)
85
93
86
- @overload
87
- def erase (self , data , fields : None ) -> str : ...
88
-
89
- @overload
90
- def erase (self , data : list , fields : list [str ]) -> list [str ]: ...
91
-
92
- @overload
93
- def erase (self , data : tuple , fields : list [str ]) -> tuple [str ]: ...
94
-
95
- @overload
96
- def erase (self , data : dict , fields : list [str ]) -> dict : ...
97
-
98
- @overload
99
- def erase (self , data : dict [Any , Any ], * , masking_rules : dict [str , object ]) -> dict [Any , Any ]: ...
100
-
101
- @overload
102
- def erase (
103
- self ,
104
- data : dict ,
105
- fields : list [str ],
106
- dynamic_mask : bool | None = None ,
107
- custom_mask : str | None = None ,
108
- regex_pattern : str | None = None ,
109
- mask_format : str | None = None ,
110
- ) -> dict : ...
111
-
112
94
def erase (
113
95
self ,
114
- data : Sequence | Mapping ,
96
+ data : Any ,
115
97
fields : list [str ] | None = None ,
116
98
dynamic_mask : bool | None = None ,
117
99
custom_mask : str | None = None ,
118
100
regex_pattern : str | None = None ,
119
101
mask_format : str | None = None ,
120
102
masking_rules : dict | None = None ,
121
- ) -> str | list [ str ] | tuple [ str ] | dict :
103
+ ) -> Any :
122
104
if masking_rules :
123
- return self ._apply_masking_rules (data , masking_rules )
105
+ return self ._apply_masking_rules (data = data , masking_rules = masking_rules )
124
106
else :
125
107
return self ._apply_action (
126
108
data = data ,
@@ -142,8 +124,8 @@ def _apply_action(
142
124
custom_mask : str | None = None ,
143
125
regex_pattern : str | None = None ,
144
126
mask_format : str | None = None ,
145
- ** encryption_context : str ,
146
- ):
127
+ ** kwargs : Any ,
128
+ ) -> Any :
147
129
"""
148
130
Helper method to determine whether to apply a given action to the entire input data
149
131
or to specific fields if the 'fields' argument is specified.
@@ -159,8 +141,6 @@ def _apply_action(
159
141
and returns the modified value.
160
142
provider_options : dict
161
143
Provider specific keyword arguments to propagate; used as an escape hatch.
162
- encryption_context: str
163
- Encryption context to use in encrypt and decrypt operations.
164
144
165
145
Returns
166
146
-------
@@ -179,7 +159,7 @@ def _apply_action(
179
159
custom_mask = custom_mask ,
180
160
regex_pattern = regex_pattern ,
181
161
mask_format = mask_format ,
182
- ** encryption_context ,
162
+ ** kwargs ,
183
163
)
184
164
else :
185
165
logger .debug (f"Running action { action .__name__ } with the entire data" )
@@ -190,7 +170,7 @@ def _apply_action(
190
170
custom_mask = custom_mask ,
191
171
regex_pattern = regex_pattern ,
192
172
mask_format = mask_format ,
193
- ** encryption_context ,
173
+ ** kwargs ,
194
174
)
195
175
196
176
def _apply_action_to_fields (
0 commit comments