Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion nodestream_github/client/githubclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import logging
from collections.abc import AsyncGenerator
from enum import Enum
from typing import Any

import httpx
from limits import RateLimitItem, RateLimitItemPerMinute
Expand Down Expand Up @@ -82,7 +83,7 @@ def __init__(
max_retries: int | None = None,
rate_limit_per_minute: int | None = None,
max_retry_wait_seconds: int | None = None,
**_kwargs: any,
**_kwargs: dict[str, Any],
):
if per_page is None:
per_page = DEFAULT_PAGE_SIZE
Expand Down
3 changes: 2 additions & 1 deletion nodestream_github/orgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""

from collections.abc import AsyncGenerator
from typing import Any

from nodestream.pipeline import Extractor

Expand All @@ -25,7 +26,7 @@ def __init__(
*,
include_members: bool | None = True,
include_repositories: bool | None = True,
**kwargs: any,
**kwargs: dict[str, Any],
):

self.include_members = include_members is True
Expand Down
9 changes: 5 additions & 4 deletions nodestream_github/repos.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from collections.abc import AsyncGenerator
from dataclasses import dataclass
from typing import Any

from nodestream.pipeline import Extractor

Expand All @@ -19,7 +20,7 @@
logger = get_plugin_logger(__name__)


def _dict_val_to_bool(d: dict[str, any], key: str) -> bool:
def _dict_val_to_bool(d: dict[str, Any], key: str) -> bool:
value = d.get(key)
if value is None:
return False
Expand All @@ -46,7 +47,7 @@ def user_any(self) -> bool:
return self.user_public or self.user_private

@staticmethod
def from_dict(raw_dict: dict[str, any]) -> "CollectWhichRepos":
def from_dict(raw_dict: dict[str, Any]) -> "CollectWhichRepos":
org_all = _dict_val_to_bool(raw_dict, "org_all")
user_all = _dict_val_to_bool(raw_dict, "user_all")

Expand All @@ -62,8 +63,8 @@ def from_dict(raw_dict: dict[str, any]) -> "CollectWhichRepos":
class GithubReposExtractor(Extractor):
def __init__(
self,
collecting: CollectWhichRepos | dict[str, any] | None = None,
**kwargs: any,
collecting: CollectWhichRepos | dict[str, Any] | None = None,
**kwargs: dict[str, Any],
):
if isinstance(collecting, CollectWhichRepos):
self.collecting = collecting
Expand Down
3 changes: 2 additions & 1 deletion nodestream_github/teams.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""

from collections.abc import AsyncGenerator
from typing import Any

from nodestream.pipeline import Extractor

Expand All @@ -20,7 +21,7 @@


class GithubTeamsExtractor(Extractor):
def __init__(self, **github_client_kwargs: any):
def __init__(self, **github_client_kwargs: dict[str, Any]):
self.client = GithubRestApiClient(**github_client_kwargs)

async def extract_records(self) -> AsyncGenerator[TeamRecord]:
Expand Down
3 changes: 2 additions & 1 deletion nodestream_github/transformer/repo.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
from collections.abc import AsyncGenerator
from typing import Any

from nodestream.pipeline import Transformer

Expand All @@ -17,7 +18,7 @@ def __init__(
self,
*,
full_name_key: str = "full_name",
**kwargs: any,
**kwargs: dict[str, Any],
):
self.client = GithubRestApiClient(**kwargs)
self.full_name_key = full_name_key
Expand Down
4 changes: 2 additions & 2 deletions nodestream_github/types/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ class UserRepoType(StrEnum):
MEMBER = "member"


class OrgMemberRole:
class OrgMemberRole(StrEnum):
ALL = "all"
ADMIN = "admin"
MEMBER = "member"


class TeamMemberRole:
class TeamMemberRole(StrEnum):
ALL = "all"
MAINTAINER = "maintainer"
MEMBER = "member"
3 changes: 2 additions & 1 deletion nodestream_github/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""

from collections.abc import AsyncGenerator
from typing import Any

from nodestream.pipeline import Extractor

Expand All @@ -19,7 +20,7 @@


class GithubUserExtractor(Extractor):
def __init__(self, **github_client_kwargs: any):
def __init__(self, **github_client_kwargs: dict[str, Any]):
self.client = GithubRestApiClient(**github_client_kwargs)

async def extract_records(self) -> AsyncGenerator[UserRecord]:
Expand Down
4 changes: 3 additions & 1 deletion tests/data/orgs.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from typing import Any

from nodestream_github.types import GithubOrg, GithubOrgSummary
from tests.data.util import encode_as_node_id


def org_summary(
*, org_login: str = "github", org_id: int = 1, **kwargs: any
*, org_login: str = "github", org_id: int = 1, **kwargs: dict[str, Any]
) -> GithubOrgSummary:
return {
"login": org_login,
Expand Down
6 changes: 4 additions & 2 deletions tests/data/repos.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
from typing import Any

from nodestream_github.types import GithubRepo
from tests.data.users import OCTOCAT_USER
from tests.data.util import encode_as_node_id


def repo(
*,
owner: dict[str, any] | None = None,
owner: dict[str, Any] | None = None,
repo_name: str = "Hello-World",
repo_id: int = 1296269,
**kwargs: any,
**kwargs: dict[str, Any],
) -> GithubRepo:

repo_owner = OCTOCAT_USER if owner is None else owner
Expand Down
6 changes: 4 additions & 2 deletions tests/data/teams.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Any

from nodestream_github.types import GithubOrgSummary, GithubTeam, GithubTeamSummary
from tests.data.orgs import GITHUB_ORG
from tests.data.util import encode_as_node_id
Expand All @@ -8,7 +10,7 @@ def team_summary(
team_id: int = 1,
slug: str = "justice-league",
org_login: str = "github",
**kwargs: any,
**kwargs: dict[str, Any],
) -> GithubTeamSummary:
return {
"id": team_id,
Expand All @@ -32,7 +34,7 @@ def team(
team_id: int = 1,
organization: GithubOrgSummary | None = None,
slug: str = "justice-league",
**kwargs: any,
**kwargs: dict[str, Any],
) -> GithubTeam:
org = organization if organization else GITHUB_ORG
summary = team_summary(team_id=team_id, org_login=org["login"], slug=slug)
Expand Down
9 changes: 8 additions & 1 deletion tests/data/users.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
from typing import Any

from nodestream_github.types import GithubUser
from tests.data.util import encode_as_node_id


def user(*, user_login: str = "octocat", user_id: int = 1, **kwargs: any) -> GithubUser:
def user(
*,
user_login: str = "octocat",
user_id: int = 1,
**kwargs: dict[str, Any],
) -> GithubUser:

return {
"login": f"{user_login}",
Expand Down
38 changes: 21 additions & 17 deletions tests/mocks/githubrest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# noinspection PyProtectedMember
from typing import Optional
from typing import Any, Optional

from pytest_httpx import HTTPXMock

Expand Down Expand Up @@ -41,7 +41,7 @@ def per_page(self) -> int:
def httpx_mock(self) -> HTTPXMock:
return self._httpx_mock

def add_exception(self, *, exception: Exception, **matchers: any):
def add_exception(self, *, exception: Exception, **matchers: dict[str, Any]):
self.httpx_mock.add_exception(exception, **matchers)

def add_response(
Expand All @@ -55,7 +55,7 @@ def add_response(
html: str | None = None,
stream: Optional[any] = None,
json: Optional[any] = None,
**matchers: any,
**matchers: dict[str, Any],
):
self.httpx_mock.add_response(
status_code=status_code,
Expand All @@ -69,20 +69,20 @@ def add_response(
**matchers,
)

def all_orgs(self, **kwargs: any) -> None:
def all_orgs(self, **kwargs: dict[str, Any]) -> None:
self.add_response(
url=f"{self.base_url}/organizations?per_page={self.per_page}", **kwargs
)

def get_org(self, *, org_name: str, **kwargs: any) -> None:
def get_org(self, *, org_name: str, **kwargs: dict[str, Any]) -> None:
self.add_response(url=f"{self.base_url}/orgs/{org_name}", **kwargs)

def get_members_for_org(
self,
*,
org_name: str,
role: OrgMemberRole | None = None,
**kwargs: any,
**kwargs: dict[str, Any],
) -> None:
actual_role = f"role={role}" if role else ""
self.add_response(
Expand All @@ -95,21 +95,21 @@ def get_repos_for_org(
*,
org_name: str,
repo_type: OrgRepoType | None = None,
**kwargs: any,
**kwargs: dict[str, Any],
):
type_param = f"&type={repo_type}" if repo_type else ""
self.add_response(
url=f"{self.base_url}/orgs/{org_name}/repos?per_page={self.per_page}{type_param}",
**kwargs,
)

def list_teams_for_org(self, *, org_login: str, **kwargs: any):
def list_teams_for_org(self, *, org_login: str, **kwargs: dict[str, Any]):
self.add_response(
url=f"{self.base_url}/orgs/{org_login}/teams?per_page={self.per_page}",
**kwargs,
)

def get_team(self, *, org_login: str, team_slug: str, **kwargs: any):
def get_team(self, *, org_login: str, team_slug: str, **kwargs: dict[str, Any]):
self.add_response(
url=f"{self.base_url}/orgs/{org_login}/teams/{team_slug}", **kwargs
)
Expand All @@ -119,20 +119,22 @@ def get_members_for_team(
*,
team_id: int,
role: TeamMemberRole,
**kwargs: any,
**kwargs: dict[str, Any],
):
self.add_response(
url=f"{self.base_url}/teams/{team_id}/members?per_page={self.per_page}&role={role}",
**kwargs,
)

def get_repos_for_team(self, *, org_login: str, slug: str, **kwargs: any):
def get_repos_for_team(
self, *, org_login: str, slug: str, **kwargs: dict[str, Any]
):
self.add_response(
url=f"{self.base_url}/orgs/{org_login}/teams/{slug}/repos?per_page={self.per_page}",
**kwargs,
)

def all_repos(self, **kwargs: any) -> None:
def all_repos(self, **kwargs: dict[str, Any]) -> None:
self.add_response(
url=f"{self.base_url}/repositories?per_page={self.per_page}", **kwargs
)
Expand All @@ -142,14 +144,16 @@ def get_languages_for_repo(
*,
owner_login: str,
repo_name: str,
**kwargs: any,
**kwargs: dict[str, Any],
) -> None:
self.add_response(
url=f"{self.base_url}/repos/{owner_login}/{repo_name}/languages?per_page={self.per_page}",
**kwargs,
)

def get_webhooks_for_repo(self, *, owner_login: str, repo_name: str, **kwargs: any):
def get_webhooks_for_repo(
self, *, owner_login: str, repo_name: str, **kwargs: dict[str, Any]
):
self.add_response(
url=f"{self.base_url}/repos/{owner_login}/{repo_name}/hooks?per_page={self.per_page}",
**kwargs,
Expand All @@ -161,14 +165,14 @@ def get_collaborators_for_repo(
owner_login: str,
repo_name: str,
affiliation: CollaboratorAffiliation,
**kwargs: any,
**kwargs: dict[str, Any],
) -> None:
self.add_response(
url=f"{self.base_url}/repos/{owner_login}/{repo_name}/collaborators?per_page={self.per_page}&affiliation={affiliation}",
**kwargs,
)

def all_users(self, **kwargs: any):
def all_users(self, **kwargs: dict[str, Any]):
self.add_response(
url=f"{self.base_url}/users?per_page={self.per_page}", **kwargs
)
Expand All @@ -178,7 +182,7 @@ def get_repos_for_user(
*,
user_login: str,
type_param: UserRepoType | None,
**kwargs: any,
**kwargs: dict[str, Any],
):
type_param = f"&type={type_param}" if type_param else ""
self.add_response(
Expand Down
Loading