77
88
99def to_int (
10- input_ : typing .Optional [str ] = None ,
11- default : int = 0 ,
12- exception : types .ExceptionsType = (ValueError , TypeError ),
13- regexp : types .O [types .Pattern ] = None ,
10+ input_ : typing .Optional [str ] = None ,
11+ default : int = 0 ,
12+ exception : types .ExceptionsType = (ValueError , TypeError ),
13+ regexp : types .O [types .Pattern ] = None ,
1414) -> int :
1515 r'''
1616 Convert the given input to an integer or return default
@@ -97,10 +97,10 @@ def to_int(
9797
9898
9999def to_float (
100- input_ : str ,
101- default : int = 0 ,
102- exception : types .ExceptionsType = (ValueError , TypeError ),
103- regexp : types .O [types .Pattern ] = None ,
100+ input_ : str ,
101+ default : int = 0 ,
102+ exception : types .ExceptionsType = (ValueError , TypeError ),
103+ regexp : types .O [types .Pattern ] = None ,
104104) -> types .Number :
105105 r'''
106106 Convert the given `input_` to an integer or return default
@@ -174,9 +174,9 @@ def to_float(
174174
175175
176176def to_unicode (
177- input_ : types .StringTypes ,
178- encoding : str = 'utf-8' ,
179- errors : str = 'replace' ,
177+ input_ : types .StringTypes ,
178+ encoding : str = 'utf-8' ,
179+ errors : str = 'replace' ,
180180) -> str :
181181 '''Convert objects to unicode, if needed decodes string with the given
182182 encoding and errors settings.
@@ -203,9 +203,9 @@ def to_unicode(
203203
204204
205205def to_str (
206- input_ : types .StringTypes ,
207- encoding : str = 'utf-8' ,
208- errors : str = 'replace' ,
206+ input_ : types .StringTypes ,
207+ encoding : str = 'utf-8' ,
208+ errors : str = 'replace' ,
209209) -> bytes :
210210 '''Convert objects to string, encodes to the given encoding
211211
@@ -234,7 +234,8 @@ def to_str(
234234
235235
236236def scale_1024 (
237- x : types .Number , n_prefixes : int ,
237+ x : types .Number ,
238+ n_prefixes : int ,
238239) -> types .Tuple [types .Number , types .Number ]:
239240 '''Scale a number down to a suitable size, based on powers of 1024.
240241
@@ -262,9 +263,11 @@ def scale_1024(
262263
263264
264265def remap (
265- value : types .DecimalNumber ,
266- old_min : types .DecimalNumber , old_max : types .DecimalNumber ,
267- new_min : types .DecimalNumber , new_max : types .DecimalNumber ,
266+ value : types .DecimalNumber ,
267+ old_min : types .DecimalNumber ,
268+ old_max : types .DecimalNumber ,
269+ new_min : types .DecimalNumber ,
270+ new_max : types .DecimalNumber ,
268271) -> types .DecimalNumber :
269272 '''
270273 remap a value from one range into another.
@@ -340,19 +343,19 @@ def remap(
340343 '''
341344 type_ : types .Type [types .DecimalNumber ]
342345 if (
343- isinstance (value , decimal .Decimal ) or
344- isinstance (old_min , decimal .Decimal ) or
345- isinstance (old_max , decimal .Decimal ) or
346- isinstance (new_min , decimal .Decimal ) or
347- isinstance (new_max , decimal .Decimal )
346+ isinstance (value , decimal .Decimal )
347+ or isinstance (old_min , decimal .Decimal )
348+ or isinstance (old_max , decimal .Decimal )
349+ or isinstance (new_min , decimal .Decimal )
350+ or isinstance (new_max , decimal .Decimal )
348351 ):
349352 type_ = decimal .Decimal
350353 elif (
351- isinstance (value , float ) or
352- isinstance (old_min , float ) or
353- isinstance (old_max , float ) or
354- isinstance (new_min , float ) or
355- isinstance (new_max , float )
354+ isinstance (value , float )
355+ or isinstance (old_min , float )
356+ or isinstance (old_max , float )
357+ or isinstance (new_min , float )
358+ or isinstance (new_max , float )
356359 ):
357360 type_ = float
358361
@@ -369,12 +372,14 @@ def remap(
369372 new_range = new_max - new_min # type: ignore
370373
371374 if old_range == 0 :
372- raise ValueError ('Input range ({}-{}) is empty' .format (
373- old_min , old_max ))
375+ raise ValueError (
376+ 'Input range ({}-{}) is empty' .format (old_min , old_max )
377+ )
374378
375379 if new_range == 0 :
376- raise ValueError ('Output range ({}-{}) is empty' .format (
377- new_min , new_max ))
380+ raise ValueError (
381+ 'Output range ({}-{}) is empty' .format (new_min , new_max )
382+ )
378383
379384 new_value = (value - old_min ) * new_range # type: ignore
380385
0 commit comments