@@ -110,17 +110,19 @@ def from_lambda(cls, name, lambda_):
110
110
if PY2 : # pragma: no cover
111
111
a = inspect .getargspec (lambda_ )
112
112
varargs , varkw , defaults , kwonlyargs = (
113
- a .varargs , a .keywords , a .defaults , None )
113
+ a .varargs , a .keywords , a .defaults , None ,
114
+ )
114
115
else : # pragma: no cover
115
116
a = inspect .getfullargspec (lambda_ )
116
117
varargs , varkw , defaults , kwonlyargs = (
117
- a .varargs , a .varkw , a .defaults , a .kwonlyargs )
118
+ a .varargs , a .varkw , a .defaults , a .kwonlyargs ,
119
+ )
118
120
119
121
if varargs or varkw or defaults or kwonlyargs :
120
122
raise TypeError (
121
- 'functions cannot have starargs or defaults: {0 } {1 }' .format (
122
- name , lambda_
123
- )
123
+ 'functions cannot have starargs or defaults: {} {}' .format (
124
+ name , lambda_ ,
125
+ ),
124
126
)
125
127
return cls (name , a .args , lambda_ )
126
128
@@ -157,7 +159,7 @@ def __init__(self, name, arguments, callable_):
157
159
@property
158
160
def signature (self ):
159
161
"""Signature string of the function."""
160
- return '{0 }({1 })' .format (self .name , ', ' .join (self .arguments ))
162
+ return '{}({})' .format (self .name , ', ' .join (self .arguments ))
161
163
162
164
def __call__ (self , * args , ** kwargs ):
163
165
return self .callable_ (* args , ** kwargs )
@@ -177,7 +179,7 @@ def _to_importer_result(single_result):
177
179
if len (single_result ) not in (1 , 2 , 3 ):
178
180
raise ValueError (
179
181
'Expected importer result to be a tuple of length (1, 2, 3) '
180
- 'but got {0 }: {1 !r}' .format (len (single_result ), single_result )
182
+ 'but got {}: {!r}' .format (len (single_result ), single_result ),
181
183
)
182
184
183
185
def _to_bytes (obj ):
@@ -222,7 +224,7 @@ def _raise(e):
222
224
223
225
def compile_dirname (
224
226
search_path , output_path , output_style , source_comments , include_paths ,
225
- precision , custom_functions , importers , custom_import_extensions
227
+ precision , custom_functions , importers , custom_import_extensions ,
226
228
):
227
229
fs_encoding = sys .getfilesystemencoding () or sys .getdefaultencoding ()
228
230
for dirpath , _ , filenames in os .walk (search_path , onerror = _raise ):
@@ -257,10 +259,10 @@ def compile_dirname(
257
259
def _check_no_remaining_kwargs (func , kwargs ):
258
260
if kwargs :
259
261
raise TypeError (
260
- '{0 }() got unexpected keyword argument(s) {1 }' .format (
262
+ '{}() got unexpected keyword argument(s) {}' .format (
261
263
func .__name__ ,
262
- ', ' .join ("'{0 }'" .format (arg ) for arg in sorted (kwargs )),
263
- )
264
+ ', ' .join ("'{}'" .format (arg ) for arg in sorted (kwargs )),
265
+ ),
264
266
)
265
267
266
268
@@ -511,8 +513,10 @@ def my_importer(path):
511
513
if not modes :
512
514
raise TypeError ('choose one at least in ' + and_join (MODES ))
513
515
elif len (modes ) > 1 :
514
- raise TypeError (and_join (modes ) + ' are exclusive each other; '
515
- 'cannot be used at a time' )
516
+ raise TypeError (
517
+ and_join (modes ) + ' are exclusive each other; '
518
+ 'cannot be used at a time' ,
519
+ )
516
520
precision = kwargs .pop ('precision' , 5 )
517
521
output_style = kwargs .pop ('output_style' , 'nested' )
518
522
if not isinstance (output_style , string_types ):
@@ -521,29 +525,33 @@ def my_importer(path):
521
525
try :
522
526
output_style = OUTPUT_STYLES [output_style ]
523
527
except KeyError :
524
- raise CompileError ('{0 } is unsupported output_style; choose one of {1 }'
528
+ raise CompileError ('{} is unsupported output_style; choose one of {}'
525
529
'' .format (output_style , and_join (OUTPUT_STYLES )))
526
530
source_comments = kwargs .pop ('source_comments' , False )
527
531
if source_comments in SOURCE_COMMENTS :
528
532
if source_comments == 'none' :
529
- deprecation_message = ('you can simply pass False to '
530
- "source_comments instead of 'none'" )
533
+ deprecation_message = (
534
+ 'you can simply pass False to '
535
+ "source_comments instead of 'none'"
536
+ )
531
537
source_comments = False
532
538
elif source_comments in ('line_numbers' , 'default' ):
533
539
deprecation_message = ('you can simply pass True to '
534
540
"source_comments instead of " +
535
541
repr (source_comments ))
536
542
source_comments = True
537
543
else :
538
- deprecation_message = ("you don't have to pass 'map' to "
539
- 'source_comments but just need to '
540
- 'specify source_map_filename' )
544
+ deprecation_message = (
545
+ "you don't have to pass 'map' to "
546
+ 'source_comments but just need to '
547
+ 'specify source_map_filename'
548
+ )
541
549
source_comments = False
542
550
warnings .warn (
543
551
"values like 'none', 'line_numbers', and 'map' for "
544
552
'the source_comments parameter are deprecated; ' +
545
553
deprecation_message ,
546
- DeprecationWarning
554
+ DeprecationWarning ,
547
555
)
548
556
if not isinstance (source_comments , bool ):
549
557
raise TypeError ('source_comments must be bool, not ' +
@@ -559,7 +567,7 @@ def _get_file_arg(key):
559
567
if ret and 'filename' not in modes :
560
568
raise CompileError (
561
569
'{} is only available with filename= keyword argument since '
562
- 'has to be aware of it' .format (key )
570
+ 'has to be aware of it' .format (key ),
563
571
)
564
572
return ret
565
573
@@ -591,14 +599,14 @@ def _get_file_arg(key):
591
599
'- a set/sequence of {0.__module__}.{0.__name__} objects,\n '
592
600
'- a mapping of function name strings to lambda functions,\n '
593
601
'- a set/sequence of named functions,\n '
594
- 'not {1!r}' .format (SassFunction , custom_functions )
602
+ 'not {1!r}' .format (SassFunction , custom_functions ),
595
603
)
596
604
597
605
_custom_exts = kwargs .pop ('custom_import_extensions' , []) or []
598
606
if not isinstance (_custom_exts , (list , tuple )):
599
607
raise TypeError (
600
608
'custom_import_extensions must be a list of strings '
601
- 'not {}' .format (type (_custom_exts ))
609
+ 'not {}' .format (type (_custom_exts )),
602
610
)
603
611
custom_import_extensions = [ext .encode ('utf-8' ) for ext in _custom_exts ]
604
612
@@ -624,7 +632,7 @@ def _get_file_arg(key):
624
632
if not isinstance (filename , string_types ):
625
633
raise TypeError ('filename must be a string, not ' + repr (filename ))
626
634
elif not os .path .isfile (filename ):
627
- raise IOError ('{0 !r} seems not a file' .format (filename ))
635
+ raise IOError ('{!r} seems not a file' .format (filename ))
628
636
elif isinstance (filename , text_type ):
629
637
filename = filename .encode (fs_encoding )
630
638
_check_no_remaining_kwargs (compile , kwargs )
@@ -643,13 +651,15 @@ def _get_file_arg(key):
643
651
try :
644
652
search_path , output_path = kwargs .pop ('dirname' )
645
653
except ValueError :
646
- raise ValueError ('dirname must be a pair of (source_dir, '
647
- 'output_dir)' )
654
+ raise ValueError (
655
+ 'dirname must be a pair of (source_dir, '
656
+ 'output_dir)' ,
657
+ )
648
658
_check_no_remaining_kwargs (compile , kwargs )
649
659
s , v = compile_dirname (
650
660
search_path , output_path , output_style , source_comments ,
651
661
include_paths , precision , custom_functions , importers ,
652
- custom_import_extensions
662
+ custom_import_extensions ,
653
663
)
654
664
if s :
655
665
return
@@ -777,7 +787,7 @@ def __len__(self):
777
787
# Our interface
778
788
779
789
def __repr__ (self ):
780
- return '{0 }({1 })' .format (type (self ).__name__ , frozenset (self .items ()))
790
+ return '{}({})' .format (type (self ).__name__ , frozenset (self .items ()))
781
791
782
792
def __hash__ (self ):
783
793
return self ._hash
0 commit comments