@@ -45,15 +45,15 @@ def encode_multipart(boundary, http_requests):
4545
4646 for req in http_requests :
4747
48- lines .append ('--{0}' . format ( boundary ) )
48+ lines .append (f '--{ boundary } ' )
4949
5050 if not isinstance (req , MultipartRequest ):
5151 lines .extend (('Content-Type: application/http ' , 'Content-Transfer-Encoding:binary' ))
5252
5353 lines .append ('' )
5454
5555 # request line (method + path + query params)
56- line = '{method} {path}' . format ( method = req .get_method (), path = req .get_path ())
56+ line = f' { req .get_method ()} { req .get_path ()} '
5757 query_params = '&' .join (['{}={}' .format (key , val ) for key , val in req .get_query_params ().items ()])
5858 if query_params :
5959 line += '?' + query_params
@@ -63,7 +63,7 @@ def encode_multipart(boundary, http_requests):
6363
6464 # request specific headers
6565 for hdr , hdr_val in req .get_headers ().items ():
66- lines .append ('{ }: {}' . format ( hdr , hdr_val ) )
66+ lines .append (f' { hdr } : { hdr_val } ' )
6767
6868 lines .append ('' )
6969
@@ -76,7 +76,7 @@ def encode_multipart(boundary, http_requests):
7676 # 400 Bad fromat from SAP gateway
7777 lines .append ('' )
7878
79- lines .append ('--{0 }--' . format ( boundary ) )
79+ lines .append (f '--{ boundary } --' )
8080
8181 return '\r \n ' .join (lines )
8282
@@ -96,7 +96,7 @@ def decode(message):
9696 messages .append (part .get_payload ())
9797 return messages
9898
99- data = "Content-Type: {}\n " . format ( content_type ) + data
99+ data = f "Content-Type: { content_type } \n " + data
100100 parser = Parser ()
101101 parsed = parser .parsestr (data )
102102 decoded = decode (parsed )
@@ -196,7 +196,7 @@ def __init__(self, entity_type, single_key=None, **args):
196196 else :
197197 for key_prop in self ._key :
198198 if key_prop .name not in args :
199- raise PyODataException ('Missing value for key property {}' . format ( key_prop .name ) )
199+ raise PyODataException (f 'Missing value for key property { key_prop .name } ' )
200200
201201 self ._type = EntityKey .TYPE_COMPLEX
202202
@@ -220,14 +220,14 @@ def to_key_string_without_parentheses(self):
220220 # raise RuntimeError('Entity key is not complete, missing value of property: {0}'.format(key_prop.name))
221221
222222 key_pairs .append (
223- '{0 }={1}' . format ( key_prop .name , key_prop . to_literal (self ._proprties [key_prop .name ])) )
223+ f' { key_prop . name } ={ key_prop .to_literal (self ._proprties [key_prop .name ])} ' )
224224
225225 return ',' .join (key_pairs )
226226
227227 def to_key_string (self ):
228228 """Gets the string representation of the key, including parentheses"""
229229
230- return '({})' . format ( self .to_key_string_without_parentheses ())
230+ return f '({ self .to_key_string_without_parentheses ()} )'
231231
232232 def __repr__ (self ):
233233 return self .to_key_string ()
@@ -292,7 +292,7 @@ def add_headers(self, value):
292292 """
293293
294294 if not isinstance (value , dict ):
295- raise TypeError ("Headers must be of type 'dict' not {}" . format ( type (value )) )
295+ raise TypeError (f "Headers must be of type 'dict' not { type (value )} " )
296296
297297 self ._headers .update (value )
298298
@@ -420,7 +420,7 @@ def __init__(self, handler, master_key, entity_set_proxy, nav_property):
420420 self ._nav_property = nav_property
421421
422422 def get_path (self ):
423- return "{}/{}" . format ( super (NavEntityGetRequest , self ).get_path (), self ._nav_property )
423+ return f" { super (NavEntityGetRequest , self ).get_path ()} / { self ._nav_property } "
424424
425425
426426class EntityCreateRequest (ODataHttpRequest ):
@@ -586,7 +586,7 @@ def set(self, **kwargs):
586586 val = self ._entity_type .proprty (key ).to_json (val )
587587 except KeyError :
588588 raise PyODataException (
589- 'Property {} is not declared in {} entity type' . format ( key , self . _entity_type . name ) )
589+ f 'Property { key } is not declared in { self . _entity_type . name } entity type' )
590590
591591 self ._values [key ] = val
592592
@@ -858,7 +858,7 @@ def nav(self, nav_property):
858858 navigation_entity_set = self ._service .schema .entity_set (end .entity_set_name , association_info .namespace )
859859
860860 if not navigation_entity_set :
861- raise PyODataException ('No association set for role {}' . format ( navigation_property .to_role ) )
861+ raise PyODataException (f 'No association set for role { navigation_property .to_role } ' )
862862
863863 roles = navigation_property .association .end_roles
864864 if all ((role .multiplicity != model .EndRole .MULTIPLICITY_ZERO_OR_MORE for role in roles )):
@@ -974,7 +974,7 @@ def build_expression(operator, operands):
974974 if len (operands ) < 2 :
975975 raise ExpressionError ('The $filter operator \' {}\' needs at least two operands' .format (operator ))
976976
977- return '({})' . format ( ' {} ' .format (operator ).join (operands ))
977+ return f"( { ' {} ' .format (operator ).join (operands )} )"
978978
979979 @staticmethod
980980 def and_ (* operands ):
@@ -992,7 +992,7 @@ def or_(*operands):
992992 def format_filter (proprty , operator , value ):
993993 """Creates a filter expression """
994994
995- return '{ } {} {}' . format ( proprty .name , operator , proprty . to_literal (value ))
995+ return f' { proprty . name } { operator } { proprty .to_literal (value )} '
996996
997997 def __eq__ (self , value ):
998998 return GetEntitySetFilter .format_filter (self ._proprty , 'eq' , value )
@@ -1194,7 +1194,7 @@ def _build_expression(self, field_name, operator, value):
11941194
11951195 if operator == 'range' :
11961196 if not isinstance (value , (tuple , list )):
1197- raise TypeError ('Range must be tuple or list not {}' . format ( type (value )) )
1197+ raise TypeError (f 'Range must be tuple or list not { type (value )} ' )
11981198
11991199 if len (value ) != 2 :
12001200 raise ValueError ('Only two items can be passed in a range.' )
@@ -1321,7 +1321,7 @@ def nav(self, nav_property, key):
13211321
13221322 if not navigation_entity_set :
13231323 raise PyODataException (
1324- 'No association set for role {} {}' . format ( navigation_property .to_role , association_set .end_roles ) )
1324+ f 'No association set for role { navigation_property .to_role } { association_set .end_roles } ' )
13251325
13261326 roles = navigation_property .association .end_roles
13271327 if all ((role .multiplicity != model .EndRole .MULTIPLICITY_ZERO_OR_MORE for role in roles )):
@@ -1498,7 +1498,7 @@ def __getattr__(self, name):
14981498 return self ._entity_sets [name ]
14991499 except KeyError :
15001500 raise AttributeError (
1501- ' EntitySet {0 } not defined in {1}.' . format ( name , ',' .join (list (self ._entity_sets .keys ()))) )
1501+ f" EntitySet { name } not defined in { ',' .join (list (self ._entity_sets .keys ()))} ." )
15021502
15031503
15041504class FunctionContainer :
@@ -1519,7 +1519,7 @@ def __getattr__(self, name):
15191519
15201520 if name not in self ._functions :
15211521 raise AttributeError (
1522- ' Function {0 } not defined in {1}.' . format ( name , ',' .join (list (self ._functions .keys ()))) )
1522+ f" Function { name } not defined in { ',' .join (list (self ._functions .keys ()))} ." )
15231523
15241524 fimport = self ._service .schema .function_import (name )
15251525
@@ -1742,7 +1742,7 @@ def get_boundary(self):
17421742
17431743 def get_default_headers (self ):
17441744 # pylint: disable=no-self-use
1745- return {'Content-Type' : 'multipart/mixed;boundary={}' . format ( self .get_boundary ()) }
1745+ return {'Content-Type' : f 'multipart/mixed;boundary={ self .get_boundary ()} ' }
17461746
17471747 def get_body (self ):
17481748 return encode_multipart (self .get_boundary (), self .requests )
0 commit comments