You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As it stands now, 1.0 just has a few items left before it can ship.
I would love to have someone help getting 0.99 out the door. This release is as important as 1.0.
What is necessary for this release is for the following checklist to be applied to most of the breaking changes in 1.0:
Add back the definition for a method that has been removed
Add a deprecation warning
Ensure the definition, simply calls the method in 1.0
Add a unit test that checks for the calls.
Take for example, github3.iter_all_repos:
# github3/api.pydefiter_all_repos(
# params
):
warnings.warn('iter_all_repos will be removed in v1.0. You can switch to using all_repositories now.',
DeprecationWarning)
returnall_repositories(
# params
)
A slightly more complex would be GitHub#iter_gists.
# github3/github.pyclassGitHub(...):
defiter_gists(self,
# params
):
ifusernameisnotNone:
warnings.warn(
"Retrieving the a user's gists will be its own method in 1.0.""The new method is :func:`~GitHub.gists_by` and can be used immediately.",
DeprecationWarning
)
returnself.gists_by(...)
ifauthenticated:
warnings.warn(
"Retrieving the authenticated user's gists will be its own method in 1.0.""The new method is :func:`~GitHub.gists` and can be used immediately.",
DeprecationWarning
)
returnself.gists(...)
iffetch_all:
warnings.warn(
"Retrieving the all public gists will be its own method in 1.0.""The new method is :func:`~GitHub.public_gists` and can be used immediately.",
DeprecationWarning
)
returnself.public_gists(...)
Keep in mind these are just pseudo-examples. Because we will be using warnings.warn so much, a convenience/utility function such as issue_warning that might look like:
Finally, let's look at some example tests for this
# tests/unit/test_api_compat.pydeftest_iter_all_repos_calls_all_repositories(...):
"""Verify that iter_all_repos proxies to all_repositories."""withmock.patch('github3.api.all_repositories') asall_repositories:
github3.api.iter_all_repos(...)
assertall_repositories.assert_called_once_with(...)
# tests/unit/test_github_compat.pyclassTestGitHubCompat(...):
defsetUp(self):
self.gh=github3.github.GitHub()
deftest_iter_gists_calls_gists(...):
"""Verify that iter_gists proxies to gists when authenticated."""self.gh.login(...)
withmock.patch.object(self.gh, 'gists') asgists:
self.gh.iter_gists(...)
gists.assert_called_once_with(...)
deftest_iter_gists_calls_gists_by(...):
"""Verify that iter_gists proxies to gists_by when given a username."""withmock.patch.object(self.gh, 'gists_by') asgists_by:
self.gh.iter_gists('username', ...)
gists_by.assert_called_once_with('username', ...)
deftest_iter_gists_calls_public_gists(...):
"""Verify that iter_gists proxies to public_gists without auth or username."""withmock.patch.object(self.gh, 'public_gists') aspublic_gists:
self.gh.iter_gists(...)
public_gists.assert_called_once_with(...)
@sigmavirus24 you may be interested in stealing some code from Django: django/utils/deprecation.py contains a warn_about_renamed_method decorator that we've used in the past when we need to move methods around. It might make this sort of rearranging easier.
As it stands now, 1.0 just has a few items left before it can ship.
I would love to have someone help getting 0.99 out the door. This release is as important as 1.0.
What is necessary for this release is for the following checklist to be applied to most of the breaking changes in 1.0:
Take for example,
github3.iter_all_repos
:A slightly more complex would be
GitHub#iter_gists
.Keep in mind these are just pseudo-examples. Because we will be using
warnings.warn
so much, a convenience/utility function such asissue_warning
that might look like:Finally, let's look at some example tests for this
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: