1010import json
1111import logging
1212import os
13- from typing import List
13+ from typing import List , Tuple
1414
1515import requests
1616
@@ -39,7 +39,7 @@ def __init__(self, key: str = None, signing_secret: str = None):
3939 else :
4040 self .key = os .getenv ("NIGHTFALL_API_KEY" )
4141
42- if not key :
42+ if not self . key :
4343 raise NightfallUserError ("need an API key either in constructor or in NIGHTFALL_API_KEY environment var" ,
4444 40001 )
4545
@@ -52,7 +52,7 @@ def __init__(self, key: str = None, signing_secret: str = None):
5252 self .logger = logging .getLogger (__name__ )
5353
5454 def scan_text (self , texts : List [str ], detection_rules : List [DetectionRule ] = None ,
55- detection_rule_uuids : List [str ] = None ) -> [List [List [Finding ]], List [str ]]:
55+ detection_rule_uuids : List [str ] = None ) -> Tuple [List [List [Finding ]], List [str ]]:
5656 """Scan text with Nightfall.
5757
5858 This method takes the specified config and then makes
@@ -91,7 +91,7 @@ def scan_text(self, texts: List[str], detection_rules: List[DetectionRule] = Non
9191 findings = [[Finding .from_dict (f ) for f in item_findings ] for item_findings in parsed_response ["findings" ]]
9292 return findings , parsed_response .get ("redactedPayload" )
9393
94- def _scan_text_v3 (self , data ):
94+ def _scan_text_v3 (self , data : dict ):
9595 response = requests .post (
9696 url = self .TEXT_SCAN_ENDPOINT_V3 ,
9797 headers = self ._headers ,
@@ -113,7 +113,7 @@ def _scan_text_v3(self, data):
113113
114114 def scan_file (self , location : str , webhook_url : str , policy_uuid : str = None ,
115115 detection_rules : List [DetectionRule ] = None , detection_rule_uuids : List [str ] = None ,
116- ) -> [str , str ]:
116+ ) -> Tuple [str , str ]:
117117 """Scan file with Nightfall.
118118 At least one of policy_uuid, detection_rule_uuids or detection_rules is required.
119119
@@ -165,7 +165,7 @@ def _file_scan_initialize(self, location: str):
165165
166166 return response
167167
168- def _file_scan_upload (self , session_id , location : str , chunk_size : int ):
168+ def _file_scan_upload (self , session_id : str , location : str , chunk_size : int ):
169169
170170 def read_chunks (fp , chunk_size ):
171171 ix = 0
@@ -193,7 +193,7 @@ def upload_chunk(id, data, headers):
193193
194194 return True
195195
196- def _file_scan_finalize (self , session_id ):
196+ def _file_scan_finalize (self , session_id : str ):
197197 response = requests .post (
198198 url = self .FILE_SCAN_COMPLETE_ENDPOINT .format (session_id ),
199199 headers = self ._headers
0 commit comments