Skip to content

Commit e65d27b

Browse files
committed
Split out ShortTeam from Team
This also introduces consistency in the orgs module in how we set-up attributes for the *Team and *Organization classes. It also rewrites the docstrings to be consistent with the rest of the library
1 parent c68d0b3 commit e65d27b

13 files changed

+678
-297
lines changed

github3/events.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,10 @@ def _release(payload, session):
266266

267267

268268
def _team(payload, session):
269-
from .orgs import Team
269+
from .orgs import ShortTeam
270270
from .repos import ShortRepository
271271
if payload.get('team'):
272-
payload['team'] = Team(payload['team'], session)
272+
payload['team'] = ShortTeam(payload['team'], session)
273273
if payload.get('repo'):
274274
payload['repo'] = ShortRepository(payload['repo'], session)
275275
if payload.get('sender'):
@@ -278,6 +278,7 @@ def _team(payload, session):
278278

279279

280280
def identity(x, session):
281+
"""Return the value."""
281282
return x
282283

283284

github3/github.py

+23-6
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@
1717
from . import gists
1818
from .issues import ShortIssue, Issue, issue_params
1919
from .models import GitHubCore
20-
from .orgs import Membership, ShortOrganization, Organization, Team
20+
from .orgs import Membership, ShortOrganization, Organization
2121
from .projects import Project, ProjectCard, ProjectColumn
2222
from .pulls import PullRequest
2323
from .repos import repo
2424
from .search import (CodeSearchResult, IssueSearchResult,
2525
RepositorySearchResult, UserSearchResult)
2626
from .structs import SearchIterator
27+
from . import orgs
2728
from . import users
2829
from .notifications import Thread
2930
from .licenses import License
@@ -828,9 +829,22 @@ def me(self):
828829

829830
@requires_auth
830831
def membership_in(self, organization):
831-
"""Retrieve the user's membership in the specified organization."""
832-
url = self._build_url('user', 'memberships', 'orgs',
833-
str(organization))
832+
"""Retrieve the user's membership in the specified organization.
833+
834+
:param organization:
835+
the organization or organization login to retrieve the authorized
836+
user's membership in
837+
:type organization:
838+
str
839+
:type organization:
840+
:class:`~github3.orgs.Organization`
841+
:returns:
842+
the user's membership
843+
:rtype:
844+
:class:`~github3.orgs.Membership`
845+
"""
846+
organization_name = getattr(organization, 'login', organization)
847+
url = self._build_url('user', 'memberships', 'orgs', organization_name)
834848
json = self._json(self._get(url), 200)
835849
return self._instance_or_null(Membership, json)
836850

@@ -1708,10 +1722,13 @@ def user_teams(self, number=-1, etag=None):
17081722
authenticated user belongs. This method requires user or repo scope
17091723
when authenticating via OAuth.
17101724
1711-
:returns: generator of :class:`Team <github3.orgs.Team>` objects
1725+
:returns:
1726+
generator of teams
1727+
:rtype:
1728+
:class:`~github3.orgs.ShortTeam`
17121729
"""
17131730
url = self._build_url('user', 'teams')
1714-
return self._iter(int(number), url, Team, etag=etag)
1731+
return self._iter(int(number), url, orgs.ShortTeam, etag=etag)
17151732

17161733
def user_with_id(self, number):
17171734
"""Get the user's information with id ``number``.

0 commit comments

Comments
 (0)