Merge branch 'master' into python-3.5-support-removal
authorHarmon <Harmon758@gmail.com>
Fri, 8 Jan 2021 09:34:53 +0000 (03:34 -0600)
committerGitHub <noreply@github.com>
Fri, 8 Jan 2021 09:34:53 +0000 (03:34 -0600)
1  2 
README.md
tests/test_api.py
tweepy/api.py
tweepy/auth.py
tweepy/binder.py
tweepy/models.py
tweepy/parsers.py
tweepy/streaming.py

diff --cc README.md
index f2d598c3ea99d3b2c8ca46aa7a69644d26f19205,43c310e2c1e60136fe39637bd503ff7edcb2923f..c621ebdc4311f7569f724f652297ed64f2972bb0
+++ b/README.md
@@@ -24,9 -25,12 +25,12 @@@ Alternatively, install directly from th
  
      pip install git+https://github.com/tweepy/tweepy.git
  
 -Python 3.5 - 3.9 are supported.
 +Python 3.6 - 3.9 are supported.
  
- Community
- ---------
- - [Discord Chat](https://discord.gg/bJvqnhg)
+ Links
+ -----
+ - [Documentation](https://tweepy.readthedocs.io/en/latest/)
+ - [Official Discord Server](https://discord.gg/bJvqnhg)
+ - [Twitter API Documentation](https://developer.twitter.com/en/docs/twitter-api)
  
Simple merge
diff --cc tweepy/api.py
Simple merge
diff --cc tweepy/auth.py
Simple merge
index 60bdeffcefaf0ea6e6bc1ea7da0c1abeec8c7959,0597b3cb8fe0ae3174127e14f67caa93af9c1a5d..893e17686bb38a04ab99a3f7f73532edb467a157
@@@ -100,9 -99,9 +99,9 @@@ def bind_api(**config)
                  if arg is None:
                      continue
                  if k in self.session.params:
 -                    raise TweepError('Multiple values for parameter %s supplied!' % k)
 +                    raise TweepError(f'Multiple values for parameter {k} supplied!')
  
-                 self.session.params[k] = convert_to_utf8_str(arg)
+                 self.session.params[k] = str(arg)
  
              log.debug("PARAMS: %r", self.session.params)
  
              # or maximum number of retries is reached.
              retries_performed = 0
              while retries_performed < self.retry_count + 1:
-                 # handle running out of api calls
-                 if self.wait_on_rate_limit:
-                     if self._reset_time is not None:
-                         if self._remaining_calls is not None:
-                             if self._remaining_calls < 1:
-                                 sleep_time = self._reset_time - int(time.time())
-                                 if sleep_time > 0:
-                                     if self.wait_on_rate_limit_notify:
-                                         log.warning(f"Rate limit reached. Sleeping for: {sleep_time}")
-                                     time.sleep(sleep_time + 5)  # sleep for few extra sec
-                 # if self.wait_on_rate_limit and self._reset_time is not None and \
-                 #                 self._remaining_calls is not None and self._remaining_calls < 1:
-                 #     sleep_time = self._reset_time - int(time.time())
-                 #     if sleep_time > 0:
-                 #         if self.wait_on_rate_limit_notify:
-                 #             log.warning(f"Rate limit reached. Sleeping for: {sleep_time}")
-                 #         time.sleep(sleep_time + 5)  # sleep for few extra sec
+                 if (self.wait_on_rate_limit and self._reset_time is not None
+                     and self._remaining_calls is not None
+                     and self._remaining_calls < 1):
+                     # Handle running out of API calls
+                     sleep_time = self._reset_time - int(time.time())
+                     if sleep_time > 0:
+                         if self.wait_on_rate_limit_notify:
 -                            log.warning("Rate limit reached. Sleeping for: %d" % sleep_time)
++                            log.warning(f"Rate limit reached. Sleeping for: {sleep_time}")
+                         time.sleep(sleep_time + 1)  # Sleep for extra sec
  
                  # Apply authentication
                  auth = None
                                                  auth=auth,
                                                  proxies=self.api.proxy)
                  except Exception as e:
 -                    raise TweepError('Failed to send request: %s' % e).with_traceback(sys.exc_info()[2])
 +                    raise TweepError(f'Failed to send request: {e}').with_traceback(sys.exc_info()[2])
  
-                 rem_calls = resp.headers.get('x-rate-limit-remaining')
+                 if resp.status_code in (200, 204):
+                     break
  
+                 rem_calls = resp.headers.get('x-rate-limit-remaining')
                  if rem_calls is not None:
                      self._remaining_calls = int(rem_calls)
-                 elif isinstance(self._remaining_calls, int):
+                 elif self._remaining_calls is not None:
                      self._remaining_calls -= 1
                  reset_time = resp.headers.get('x-rate-limit-reset')
                  if reset_time is not None:
                      self._reset_time = int(reset_time)
index d3bdbcb5a8a82767c14a1d52356548c56c4cb49a,bafd910ecca4a3c457c66a6fab17695e5e6550a1..2e8360590ae4f8de353357aa22327c6e39335c1e
@@@ -78,11 -80,11 +80,11 @@@ class Model
          return results
  
      def __repr__(self):
 -        state = ['%s=%s' % (k, repr(v)) for (k, v) in vars(self).items()]
 -        return '%s(%s)' % (self.__class__.__name__, ', '.join(state))
 +        state = [f'{k}={v!r}' for (k, v) in vars(self).items()]
 +        return f'{self.__class__.__name__}({", ".join(state)})'
  
  
- class Status(Model):
+ class Status(Model, Hashable):
  
      @classmethod
      def parse(cls, api, json):
Simple merge
Simple merge