Restore RateLimit.rate attribute, raise deprecation warning instead

This commit is contained in:
Wan Liuyang
2018-09-12 14:53:44 +08:00
parent 54eb59cf6e
commit d92389be07
3 changed files with 24 additions and 5 deletions
+20 -3
View File
@@ -30,6 +30,8 @@
import github.GithubObject
import github.Rate
from deprecated import deprecated
class RateLimit(github.GithubObject.NonCompletableGithubObject):
"""
@@ -39,10 +41,25 @@ class RateLimit(github.GithubObject.NonCompletableGithubObject):
def __repr__(self):
return self.get__repr__({"core": self._core.value})
@property
@deprecated(reason="""
The rate object is deprecated. If you're writing new API client code
or updating existing code, you should use the core object instead of
the rate object. The core object contains the same information that
is present in the rate object.
""")
def rate(self):
"""
(Deprecated) Rate limit for non-search-related API, use `core` instead
:type: class:`github.Rate.Rate`
"""
return self._core.value
@property
def core(self):
"""
Rate limit for rest of the API.
Rate limit for the non-search-related API
:type: class:`github.Rate.Rate`
"""
@@ -51,7 +68,7 @@ class RateLimit(github.GithubObject.NonCompletableGithubObject):
@property
def search(self):
"""
Rate limit for Search API.
Rate limit for the Search API.
:type: class:`github.Rate.Rate`
"""
@@ -60,7 +77,7 @@ class RateLimit(github.GithubObject.NonCompletableGithubObject):
@property
def graphql(self):
"""
Experimental rate limit for GraphQL, use with caution.
(Experimental) Rate limit for GraphQL API, use with caution.
:type: class:`github.Rate.Rate`
"""
+2 -1
View File
@@ -1,4 +1,5 @@
requests>=2.14.0
pyjwt
sphinx<1.8
sphinx-rtd-theme<0.5
sphinx-rtd-theme<0.5
Deprecated
+2 -1
View File
@@ -106,7 +106,8 @@ if __name__ == "__main__":
python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*",
install_requires=[
"requests>=2.14.0",
"pyjwt"
"pyjwt",
"Deprecated"
],
extras_require = {
"integrations": ["cryptography"]