@@ -23,7 +23,8 @@ def _file_new(short_path, *, path = None, is_source = True, owner = None):
2323
2424 Args:
2525 short_path: {type}`string` The short path to the file.
26- path: {type}`string` The full path to the file. Defaults to a made up exec-root path or the short path if is_source.
26+ path: {type}`string` The full path to the file. Defaults to a made
27+ up exec-root path or the short path if is_source.
2728 is_source: {type}`bool` Whether the file is a source file.
2829 owner: {type}`Label|string` The owner label of the file.
2930
@@ -53,7 +54,10 @@ def _file_new(short_path, *, path = None, is_source = True, owner = None):
5354 if is_source :
5455 path = "external/{}/{}" .format (repo_name , rel_path )
5556 else :
56- path = "bazel-out/k9-deadbeef/bin/external/{}/{}" .format (repo_name , rel_path )
57+ path = "bazel-out/k9-deadbeef/bin/external/{}/{}" .format (
58+ repo_name ,
59+ rel_path ,
60+ )
5761 elif path == None :
5862 if is_source :
5963 path = short_path
@@ -108,8 +112,28 @@ def _mctx_read(self, x, watch = None):
108112def _mctx_path (self , x ):
109113 return _path_new (str (x ), self .mock_files )
110114
111- def _mctx_download (self , url , output = "" , sha256 = "" , executable = False , allow_fail = False , canonical_id = "" , auth = {}, headers = {}, integrity = "" , block = True ):
112- _ = sha256 , executable , allow_fail , canonical_id , auth , headers , integrity , block # @unused
115+ def _mctx_download (
116+ self ,
117+ url ,
118+ output = "" ,
119+ sha256 = "" ,
120+ executable = False ,
121+ allow_fail = False ,
122+ canonical_id = "" ,
123+ auth = {},
124+ headers = {},
125+ integrity = "" ,
126+ block = True ):
127+ _ = (
128+ sha256 ,
129+ executable ,
130+ allow_fail ,
131+ canonical_id ,
132+ auth ,
133+ headers ,
134+ integrity ,
135+ block ,
136+ ) # @unused
113137 urls = url if type (url ) == "list" else [url ]
114138 for u in urls :
115139 content = None
@@ -122,9 +146,23 @@ def _mctx_download(self, url, output = "", sha256 = "", executable = False, allo
122146 if type (content ) == "string" :
123147 out = str (output ) if output else u .split ("/" )[- 1 ]
124148 self .mock_files [out ] = content
125- return struct (success = True , wait = lambda : struct (success = True ))
149+ return struct (
150+ success = True ,
151+ wait = lambda : struct (success = True ),
152+ )
126153 else :
127- return content (self , u , output , sha256 , executable , allow_fail , canonical_id , auth , headers , integrity )
154+ return content (
155+ self ,
156+ u ,
157+ output ,
158+ sha256 ,
159+ executable ,
160+ allow_fail ,
161+ canonical_id ,
162+ auth ,
163+ headers ,
164+ integrity ,
165+ )
128166
129167 if not self .mock_downloads :
130168 return struct (success = True , wait = lambda : struct (success = True ))
@@ -146,7 +184,8 @@ def _mctx_add_module(self, **kwargs):
146184 """
147185 module = _module_new (** kwargs )
148186 if module .is_root and len (self .modules ) > 0 :
149- fail ("is_root=True can only be set on the first module in the modules list." )
187+ fail ("is_root=True can only be set on the first module in the " +
188+ "modules list." )
150189 self .modules .append (module )
151190 return self
152191
@@ -163,10 +202,13 @@ def _mctx_new(
163202
164203 Args:
165204 *args: {type}`list[MockModule]` Mock modules passed positionally.
166- modules: {type}`list[MockModule]` List of mock modules (alternative to positional args).
205+ modules: {type}`list[MockModule]` List of mock modules (alternative
206+ to positional args).
167207 environ: {type}`dict[string, string]` Dict of environment variables.
168- mock_files: {type}`dict[string, string]` Dict mapping path strings to content.
169- mock_downloads: {type}`dict[string, string|callable]` Dict mapping url to string or callable.
208+ mock_files: {type}`dict[string, string]` Dict mapping path strings
209+ to content.
210+ mock_downloads: {type}`dict[string, string|callable]` Dict mapping
211+ url to string or callable.
170212 os_name: {type}`string` The OS name.
171213 arch_name: {type}`string` The architecture name.
172214 facts: {type}`dict` Optional facts dict.
@@ -178,7 +220,8 @@ def _mctx_new(
178220
179221 for i , mod in enumerate (modules ):
180222 if getattr (mod , "is_root" , False ) and i != 0 :
181- fail ("is_root=True can only be set on the first module in the modules list." )
223+ fail ("is_root=True can only be set on the first module in the " +
224+ "modules list." )
182225
183226 environ = environ or {}
184227 mock_files = mock_files or {}
@@ -260,8 +303,26 @@ def _rctx_which(self, program):
260303 return _path_new (res , self .mock_files )
261304 return None
262305
263- def _rctx_download (self , url , output = "" , sha256 = "" , executable = False , allow_fail = False , canonical_id = "" , auth = {}, headers = {}, integrity = "" ):
264- _ = sha256 , executable , allow_fail , canonical_id , auth , headers , integrity # @unused
306+ def _rctx_download (
307+ self ,
308+ url ,
309+ output = "" ,
310+ sha256 = "" ,
311+ executable = False ,
312+ allow_fail = False ,
313+ canonical_id = "" ,
314+ auth = {},
315+ headers = {},
316+ integrity = "" ):
317+ _ = (
318+ sha256 ,
319+ executable ,
320+ allow_fail ,
321+ canonical_id ,
322+ auth ,
323+ headers ,
324+ integrity ,
325+ ) # @unused
265326
266327 urls = url if type (url ) == "list" else [url ]
267328
@@ -273,14 +334,47 @@ def _rctx_download(self, url, output = "", sha256 = "", executable = False, allo
273334 self .mock_files [str (output )] = res
274335 return struct (success = True , sha256 = "mocksha256" )
275336 else :
276- return res (self , u , output , sha256 , executable , allow_fail , canonical_id , auth , headers , integrity )
337+ return res (
338+ self ,
339+ u ,
340+ output ,
341+ sha256 ,
342+ executable ,
343+ allow_fail ,
344+ canonical_id ,
345+ auth ,
346+ headers ,
347+ integrity ,
348+ )
277349
278350 if not allow_fail :
279351 fail ("Download not mocked for url: " + str (urls ))
280352 return struct (success = False )
281353
282- def _rctx_download_and_extract (self , url , output = "" , sha256 = "" , type = "" , stripPrefix = "" , allow_fail = False , canonical_id = "" , auth = {}, headers = {}, integrity = "" , rename_files = {}):
283- _ = sha256 , type , stripPrefix , allow_fail , canonical_id , auth , headers , integrity , rename_files # @unused
354+ def _rctx_download_and_extract (
355+ self ,
356+ url ,
357+ output = "" ,
358+ sha256 = "" ,
359+ type = "" ,
360+ stripPrefix = "" ,
361+ allow_fail = False ,
362+ canonical_id = "" ,
363+ auth = {},
364+ headers = {},
365+ integrity = "" ,
366+ rename_files = {}):
367+ _ = (
368+ sha256 ,
369+ type ,
370+ stripPrefix ,
371+ allow_fail ,
372+ canonical_id ,
373+ auth ,
374+ headers ,
375+ integrity ,
376+ rename_files ,
377+ ) # @unused
284378
285379 urls = url if type (url ) == "list" else [url ]
286380
@@ -290,14 +384,42 @@ def _rctx_download_and_extract(self, url, output = "", sha256 = "", type = "", s
290384 if type (res ) == "string" :
291385 pass
292386 else :
293- return res (self , u , output , sha256 , type , stripPrefix , allow_fail , canonical_id , auth , headers , integrity , rename_files )
387+ return res (
388+ self ,
389+ u ,
390+ output ,
391+ sha256 ,
392+ type ,
393+ stripPrefix ,
394+ allow_fail ,
395+ canonical_id ,
396+ auth ,
397+ headers ,
398+ integrity ,
399+ rename_files ,
400+ )
294401
295402 if not allow_fail :
296403 fail ("Download and extract not mocked for url: " + str (urls ))
297404 return struct (success = False )
298405
299- def _rctx_execute (self , arguments , timeout = 600 , quiet = True , working_directory = "" , environment = {}, custom_reporter = "" ):
300- _ = self , arguments , timeout , quiet , working_directory , environment , custom_reporter # @unused
406+ def _rctx_execute (
407+ self ,
408+ arguments ,
409+ timeout = 600 ,
410+ quiet = True ,
411+ working_directory = "" ,
412+ environment = {},
413+ custom_reporter = "" ):
414+ _ = (
415+ self ,
416+ arguments ,
417+ timeout ,
418+ quiet ,
419+ working_directory ,
420+ environment ,
421+ custom_reporter ,
422+ ) # @unused
301423 return struct (return_code = 0 , stdout = "" , stderr = "" )
302424
303425def _rctx_symlink (self , target , link_name ):
@@ -316,9 +438,12 @@ def _rctx_new(
316438 Args:
317439 attr: {type}`dict` Dict of attributes.
318440 environ: {type}`dict[string, string]` Dict of environment variables.
319- mock_files: {type}`dict[string, string]` Dict mapping path strings to content.
320- mock_which: {type}`dict[string, string]` Dict mapping program name to path string.
321- mock_downloads: {type}`dict[string, string|callable]` Dict mapping url to string or callable.
441+ mock_files: {type}`dict[string, string]` Dict mapping path strings
442+ to content.
443+ mock_which: {type}`dict[string, string]` Dict mapping program
444+ name to path string.
445+ mock_downloads: {type}`dict[string, string|callable]` Dict mapping
446+ url to string or callable.
322447 os_name: {type}`string` The OS name.
323448 arch_name: {type}`string` The architecture name.
324449
@@ -348,7 +473,11 @@ def _rctx_new(
348473 template = lambda * a , ** k : _rctx_template (self , * a , ** k ),
349474 which = lambda * a , ** k : _rctx_which (self , * a , ** k ),
350475 download = lambda * a , ** k : _rctx_download (self , * a , ** k ),
351- download_and_extract = lambda * a , ** k : _rctx_download_and_extract (self , * a , ** k ),
476+ download_and_extract = lambda * a , ** k : _rctx_download_and_extract (
477+ self ,
478+ * a ,
479+ ** k
480+ ),
352481 execute = lambda * a , ** k : _rctx_execute (self , * a , ** k ),
353482 symlink = lambda * a , ** k : _rctx_symlink (self , * a , ** k ),
354483 )
@@ -374,7 +503,8 @@ def _glob_new():
374503 """Create a mock glob object.
375504
376505 Returns:
377- {type}`MockGlob` A struct with calls and results lists, and a glob function.
506+ {type}`MockGlob` A struct with calls and results lists, and a
507+ glob function.
378508 """
379509 calls = []
380510 results = []
0 commit comments