@@ -110,17 +110,19 @@ def from_lambda(cls, name, lambda_):
110110 if PY2 : # pragma: no cover
111111 a = inspect .getargspec (lambda_ )
112112 varargs , varkw , defaults , kwonlyargs = (
113- a .varargs , a .keywords , a .defaults , None )
113+ a .varargs , a .keywords , a .defaults , None ,
114+ )
114115 else : # pragma: no cover
115116 a = inspect .getfullargspec (lambda_ )
116117 varargs , varkw , defaults , kwonlyargs = (
117- a .varargs , a .varkw , a .defaults , a .kwonlyargs )
118+ a .varargs , a .varkw , a .defaults , a .kwonlyargs ,
119+ )
118120
119121 if varargs or varkw or defaults or kwonlyargs :
120122 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+ ),
124126 )
125127 return cls (name , a .args , lambda_ )
126128
@@ -157,7 +159,7 @@ def __init__(self, name, arguments, callable_):
157159 @property
158160 def signature (self ):
159161 """Signature string of the function."""
160- return '{0 }({1 })' .format (self .name , ', ' .join (self .arguments ))
162+ return '{}({})' .format (self .name , ', ' .join (self .arguments ))
161163
162164 def __call__ (self , * args , ** kwargs ):
163165 return self .callable_ (* args , ** kwargs )
@@ -177,7 +179,7 @@ def _to_importer_result(single_result):
177179 if len (single_result ) not in (1 , 2 , 3 ):
178180 raise ValueError (
179181 '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 ),
181183 )
182184
183185 def _to_bytes (obj ):
@@ -222,7 +224,7 @@ def _raise(e):
222224
223225def compile_dirname (
224226 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 ,
226228):
227229 fs_encoding = sys .getfilesystemencoding () or sys .getdefaultencoding ()
228230 for dirpath , _ , filenames in os .walk (search_path , onerror = _raise ):
@@ -257,10 +259,10 @@ def compile_dirname(
257259def _check_no_remaining_kwargs (func , kwargs ):
258260 if kwargs :
259261 raise TypeError (
260- '{0 }() got unexpected keyword argument(s) {1 }' .format (
262+ '{}() got unexpected keyword argument(s) {}' .format (
261263 func .__name__ ,
262- ', ' .join ("'{0 }'" .format (arg ) for arg in sorted (kwargs )),
263- )
264+ ', ' .join ("'{}'" .format (arg ) for arg in sorted (kwargs )),
265+ ),
264266 )
265267
266268
@@ -511,8 +513,10 @@ def my_importer(path):
511513 if not modes :
512514 raise TypeError ('choose one at least in ' + and_join (MODES ))
513515 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+ )
516520 precision = kwargs .pop ('precision' , 5 )
517521 output_style = kwargs .pop ('output_style' , 'nested' )
518522 if not isinstance (output_style , string_types ):
@@ -521,29 +525,33 @@ def my_importer(path):
521525 try :
522526 output_style = OUTPUT_STYLES [output_style ]
523527 except KeyError :
524- raise CompileError ('{0 } is unsupported output_style; choose one of {1 }'
528+ raise CompileError ('{} is unsupported output_style; choose one of {}'
525529 '' .format (output_style , and_join (OUTPUT_STYLES )))
526530 source_comments = kwargs .pop ('source_comments' , False )
527531 if source_comments in SOURCE_COMMENTS :
528532 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+ )
531537 source_comments = False
532538 elif source_comments in ('line_numbers' , 'default' ):
533539 deprecation_message = ('you can simply pass True to '
534540 "source_comments instead of " +
535541 repr (source_comments ))
536542 source_comments = True
537543 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+ )
541549 source_comments = False
542550 warnings .warn (
543551 "values like 'none', 'line_numbers', and 'map' for "
544552 'the source_comments parameter are deprecated; ' +
545553 deprecation_message ,
546- DeprecationWarning
554+ DeprecationWarning ,
547555 )
548556 if not isinstance (source_comments , bool ):
549557 raise TypeError ('source_comments must be bool, not ' +
@@ -559,7 +567,7 @@ def _get_file_arg(key):
559567 if ret and 'filename' not in modes :
560568 raise CompileError (
561569 '{} 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 ),
563571 )
564572 return ret
565573
@@ -591,14 +599,14 @@ def _get_file_arg(key):
591599 '- a set/sequence of {0.__module__}.{0.__name__} objects,\n '
592600 '- a mapping of function name strings to lambda functions,\n '
593601 '- a set/sequence of named functions,\n '
594- 'not {1!r}' .format (SassFunction , custom_functions )
602+ 'not {1!r}' .format (SassFunction , custom_functions ),
595603 )
596604
597605 _custom_exts = kwargs .pop ('custom_import_extensions' , []) or []
598606 if not isinstance (_custom_exts , (list , tuple )):
599607 raise TypeError (
600608 'custom_import_extensions must be a list of strings '
601- 'not {}' .format (type (_custom_exts ))
609+ 'not {}' .format (type (_custom_exts )),
602610 )
603611 custom_import_extensions = [ext .encode ('utf-8' ) for ext in _custom_exts ]
604612
@@ -624,7 +632,7 @@ def _get_file_arg(key):
624632 if not isinstance (filename , string_types ):
625633 raise TypeError ('filename must be a string, not ' + repr (filename ))
626634 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 ))
628636 elif isinstance (filename , text_type ):
629637 filename = filename .encode (fs_encoding )
630638 _check_no_remaining_kwargs (compile , kwargs )
@@ -643,13 +651,15 @@ def _get_file_arg(key):
643651 try :
644652 search_path , output_path = kwargs .pop ('dirname' )
645653 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+ )
648658 _check_no_remaining_kwargs (compile , kwargs )
649659 s , v = compile_dirname (
650660 search_path , output_path , output_style , source_comments ,
651661 include_paths , precision , custom_functions , importers ,
652- custom_import_extensions
662+ custom_import_extensions ,
653663 )
654664 if s :
655665 return
@@ -777,7 +787,7 @@ def __len__(self):
777787 # Our interface
778788
779789 def __repr__ (self ):
780- return '{0 }({1 })' .format (type (self ).__name__ , frozenset (self .items ()))
790+ return '{}({})' .format (type (self ).__name__ , frozenset (self .items ()))
781791
782792 def __hash__ (self ):
783793 return self ._hash
0 commit comments