code: def check_repo_teams(repo, allow_teams, deny_teams, team_names=None):
      
      assert isinstance(repo, github.Repository.Repository), type(repo)
  
      # fetch team names if a list was not passed
      if not team_names:
          try:
              team_names = [t.name for t in repo.get_teams()]
          except github.RateLimitExceededException:
              raise
          except github.GithubException as e:
              msg = 'error getting teams'
              raise CaughtRepositoryError(repo, e, msg) from None
  
      if not any(x in team_names for x in allow_teams)\
         or any(x in team_names for x in deny_teams):
          raise RepositoryTeamMembershipError(
              repo,
              team_names,
              allow_teams=allow_teams,
              deny_teams=deny_teams
          )
docs: Check if repo teams match allow/deny lists
  
      Parameters
      ----------
      repo: github.Repository.Repository
          repo to check for membership
  
      allow_teams: list(str)
          list of team names that repo MUST belong to at least one of.
  
      deny_teams: list(str)
          list of team that repo MUST NOT be a member of.
  
      team_names: list(str)
          list of the team name which the repo is a member of (optional).
          Providing this list saves retrieving the list of teams from the github
          API.
  
      Raises
      ------
      RepositoryTeamMembershipError
          Upon permission error