@@ -61,9 +61,9 @@ def get_ignored_lines(filename: str) -> Set[int]:
6161 return ignored_lines
6262
6363
64- def get_response_from_api (content , url , api_key , enabled_entity_list , blocked_list ):
64+ def get_response_from_api (content , url , enabled_entity_list , blocked_list ):
6565 payload = get_payload (content , enabled_entity_list , blocked_list )
66- headers = {"Content-Type" : "application/json" , "X-API-KEY" : api_key }
66+ headers = {"Content-Type" : "application/json" }
6767
6868 response = requests .post (url , json = payload , headers = headers )
6969 response .raise_for_status ()
@@ -106,7 +106,7 @@ class PiiResult:
106106 entity_type : str
107107
108108
109- def check_for_pii (filename : str , url : str , api_key : str , enabled_entity_list : List [str ], blocked_list : List [str ]) -> List [PiiResult ]:
109+ def check_for_pii (filename : str , url : str , enabled_entity_list : List [str ], blocked_list : List [str ]) -> List [PiiResult ]:
110110
111111 if not os .path .getsize (filename ):
112112 # dont't expect PII in empty files
@@ -121,7 +121,7 @@ def check_for_pii(filename: str, url: str, api_key: str, enabled_entity_list: Li
121121 # this contains also context around the added lines
122122 added_text = ["" .join (hunk .target ) for hunk in hunks ]
123123
124- api_pii_results = get_response_from_api (added_text , url , api_key , enabled_entity_list , blocked_list )
124+ api_pii_results = get_response_from_api (added_text , url , enabled_entity_list , blocked_list )
125125 ignored_lines = get_ignored_lines (filename )
126126
127127 pii_results : List [PiiResult ] = []
@@ -158,11 +158,6 @@ def main():
158158 dotenv_path = Path (os .environ ["PWD" ], args .env_file_path )
159159 load_dotenv (dotenv_path = dotenv_path )
160160
161- if "API_KEY" in os .environ :
162- API_KEY = os .environ ["API_KEY" ]
163- else :
164- sys .exit ("Your .env file is missing from the provided path or does not contain API_KEY" )
165-
166161 enabled_entity_list = [item .upper () for item in args .enabled_entities ]
167162
168163 blocked_list = [blocked for blocked in args .blocked_list ] if args .blocked_list else []
@@ -171,7 +166,7 @@ def main():
171166 pii_results = [
172167 result
173168 for filename in args .filenames
174- for result in check_for_pii (os .path .abspath (filename ), args .url , API_KEY , enabled_entity_list , blocked_list )
169+ for result in check_for_pii (os .path .abspath (filename ), args .url , enabled_entity_list , blocked_list )
175170 ]
176171 except RuntimeError as e :
177172 print (e )
0 commit comments