Replace str.format usage with f-strings
authorHarmon <Harmon758@gmail.com>
Mon, 28 Dec 2020 04:59:24 +0000 (22:59 -0600)
committerHarmon <Harmon758@gmail.com>
Mon, 28 Dec 2020 04:59:39 +0000 (22:59 -0600)
bindings_url_parser.py
tweepy/api.py

index fd5f63222311bbb42ff185a3af68b1b09d5f644c..b166ed0006597737e4d235349624a551a36b0d5e 100644 (file)
@@ -8,7 +8,7 @@ import requests
 __author__ = 'jordiriera'
 
 url_root = 'https://dev.twitter.com'
-reference_line = re.compile(':reference: ({}.*) "'.format(url_root))
+reference_line = re.compile(f':reference: ({url_root}.*) "')
 
 
 def parse(filename):
index e514fc6a9743130a0108879666e5bf1a897111ef..46aa8bd5d9245341965e622be233934a0fa79712 100644 (file)
@@ -78,11 +78,8 @@ class API:
         parser_type = Parser
         if not isinstance(self.parser, parser_type):
             raise TypeError(
-                '"parser" argument has to be an instance of "{required}".'
-                ' It is currently a {actual}.'.format(
-                    required=parser_type.__name__,
-                    actual=type(self.parser)
-                )
+                f'"parser" argument has to be an instance of "{parser_type.__name__}".'
+                f' It is currently a {type(self.parser)}.'
             )
 
     @property
@@ -1289,7 +1286,7 @@ class API:
         """
         return bind_api(
             api=self,
-            path='/tweets/search/30day/{}.json'.format(environment_name),
+            path=f'/tweets/search/30day/{environment_name}.json',
             payload_type='status', payload_list=True,
             allowed_param=['query', 'tag', 'fromDate', 'toDate', 'maxResults',
                            'next'],
@@ -1304,7 +1301,7 @@ class API:
         """
         return bind_api(
             api=self,
-            path='/tweets/search/fullarchive/{}.json'.format(environment_name),
+            path=f'/tweets/search/fullarchive/{environment_name}.json',
             payload_type='status', payload_list=True,
             allowed_param=['query', 'tag', 'fromDate', 'toDate', 'maxResults',
                            'next'],
@@ -1414,10 +1411,10 @@ class API:
         BOUNDARY = b'Tw3ePy'
         body = []
         body.append(b'--' + BOUNDARY)
-        body.append('Content-Disposition: form-data; name="{0}";'
-                    ' filename="{1}"'.format(form_field, filename)
+        body.append(f'Content-Disposition: form-data; name="{form_field}";'
+                    f' filename="{filename}"'
                     .encode('utf-8'))
-        body.append('Content-Type: {0}'.format(file_type).encode('utf-8'))
+        body.append(f'Content-Type: {file_type}'.encode('utf-8'))
         body.append(b'')
         body.append(fp.read())
         body.append(b'--' + BOUNDARY + b'--')