From 58d587c89d5676a052c0ed3bef462a75305dbb8b Mon Sep 17 00:00:00 2001 From: Jon Bristow Date: Thu, 20 Mar 2025 09:43:55 -0700 Subject: [PATCH 1/2] fix: set kwargs to any --- nodestream_github/audit.py | 2 +- nodestream_github/client/githubclient.py | 2 +- nodestream_github/orgs.py | 2 +- nodestream_github/repos.py | 2 +- nodestream_github/teams.py | 2 +- nodestream_github/transformer/repo.py | 2 +- nodestream_github/types/__init__.py | 2 +- nodestream_github/users.py | 2 +- pyproject.toml | 5 ++-- tests/data/orgs.py | 2 +- tests/data/repos.py | 2 +- tests/data/teams.py | 4 +-- tests/data/users.py | 2 +- tests/mocks/githubrest.py | 38 +++++++++++------------- 14 files changed, 33 insertions(+), 36 deletions(-) diff --git a/nodestream_github/audit.py b/nodestream_github/audit.py index cbd63eb..c0c7e6d 100644 --- a/nodestream_github/audit.py +++ b/nodestream_github/audit.py @@ -33,7 +33,7 @@ def __init__( enterprise_name: str, actions: list[str] | None = None, lookback_period: dict[str, int] | None = None, - **github_client_kwargs: dict[str, Any] | None, + **github_client_kwargs: Any | None, ): self.enterprise_name = enterprise_name self.client = GithubRestApiClient(**github_client_kwargs) diff --git a/nodestream_github/client/githubclient.py b/nodestream_github/client/githubclient.py index f66d7a8..ec619bc 100644 --- a/nodestream_github/client/githubclient.py +++ b/nodestream_github/client/githubclient.py @@ -85,7 +85,7 @@ def __init__( max_retries: int | None = None, rate_limit_per_minute: int | None = None, max_retry_wait_seconds: int | None = None, - **_kwargs: dict[str, Any], + **_kwargs: Any, ): if per_page is None: per_page = DEFAULT_PAGE_SIZE diff --git a/nodestream_github/orgs.py b/nodestream_github/orgs.py index 3a0dfa2..81e2902 100644 --- a/nodestream_github/orgs.py +++ b/nodestream_github/orgs.py @@ -26,7 +26,7 @@ def __init__( *, include_members: bool | None = True, include_repositories: bool | None = True, - **kwargs: dict[str, Any], + **kwargs: Any, ): self.include_members = include_members is True diff --git a/nodestream_github/repos.py b/nodestream_github/repos.py index b95308a..68cfca0 100644 --- a/nodestream_github/repos.py +++ b/nodestream_github/repos.py @@ -64,7 +64,7 @@ class GithubReposExtractor(Extractor): def __init__( self, collecting: CollectWhichRepos | dict[str, Any] | None = None, - **kwargs: dict[str, Any], + **kwargs: Any, ): if isinstance(collecting, CollectWhichRepos): self.collecting = collecting diff --git a/nodestream_github/teams.py b/nodestream_github/teams.py index 63fecc9..cb8ba30 100644 --- a/nodestream_github/teams.py +++ b/nodestream_github/teams.py @@ -21,7 +21,7 @@ class GithubTeamsExtractor(Extractor): - def __init__(self, **github_client_kwargs: dict[str, Any]): + def __init__(self, **github_client_kwargs: Any): self.client = GithubRestApiClient(**github_client_kwargs) async def extract_records(self) -> AsyncGenerator[TeamRecord]: diff --git a/nodestream_github/transformer/repo.py b/nodestream_github/transformer/repo.py index b668757..b01a0fe 100644 --- a/nodestream_github/transformer/repo.py +++ b/nodestream_github/transformer/repo.py @@ -18,7 +18,7 @@ def __init__( self, *, full_name_key: str = "full_name", - **kwargs: dict[str, Any], + **kwargs: Any, ): self.client = GithubRestApiClient(**kwargs) self.full_name_key = full_name_key diff --git a/nodestream_github/types/__init__.py b/nodestream_github/types/__init__.py index f2dfaa7..9860cc9 100644 --- a/nodestream_github/types/__init__.py +++ b/nodestream_github/types/__init__.py @@ -19,12 +19,12 @@ from .httpx import HeaderTypes, PrimitiveData, QueryParamTypes __all__ = [ + "GithubAuditLog", "GithubOrg", "GithubOrgSummary", "GithubRepo", "GithubTeam", "GithubTeamSummary", - "GithubAuditLog", "GithubUser", "HeaderTypes", "JSONType", diff --git a/nodestream_github/users.py b/nodestream_github/users.py index 4942d9e..bbb7459 100644 --- a/nodestream_github/users.py +++ b/nodestream_github/users.py @@ -20,7 +20,7 @@ class GithubUserExtractor(Extractor): - def __init__(self, **github_client_kwargs: dict[str, Any]): + def __init__(self, **github_client_kwargs: Any): self.client = GithubRestApiClient(**github_client_kwargs) async def extract_records(self) -> AsyncGenerator[UserRecord]: diff --git a/pyproject.toml b/pyproject.toml index 5b24044..130a348 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,14 +54,15 @@ addopts = "--cov-report=term --cov-report=xml --cov=nodestream_github --junit-xm [tool.ruff.lint] select = ["A", "ANN", "ARG", "ASYNC", "B", "C4", "DTZ", "E", "EM", "ERA", "F", "FBT", "FURB", "G", "I", "INP", "N", "PIE", "PT", "RET", "RUF", "S", "SIM", "T20", "TC", "UP", ] ignore = [] - unfixable = ["B"] - dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" + [tool.ruff.lint.per-file-ignores] "tests/*" = ["S101", "S106"] "nodestream_github/logging/__init__.py" = ["A005"] "nodestream_github/types/__init__.py" = ["A005"] + [tool.ruff.lint.flake8-annotations] mypy-init-return = true suppress-none-returning = true +allow-star-arg-any = true diff --git a/tests/data/orgs.py b/tests/data/orgs.py index 37417fe..02b3715 100644 --- a/tests/data/orgs.py +++ b/tests/data/orgs.py @@ -5,7 +5,7 @@ def org_summary( - *, org_login: str = "github", org_id: int = 1, **kwargs: dict[str, Any] + *, org_login: str = "github", org_id: int = 1, **kwargs: Any ) -> GithubOrgSummary: return { "login": org_login, diff --git a/tests/data/repos.py b/tests/data/repos.py index 3326976..9e28fce 100644 --- a/tests/data/repos.py +++ b/tests/data/repos.py @@ -10,7 +10,7 @@ def repo( owner: dict[str, Any] | None = None, repo_name: str = "Hello-World", repo_id: int = 1296269, - **kwargs: dict[str, Any], + **kwargs: Any, ) -> GithubRepo: repo_owner = OCTOCAT_USER if owner is None else owner diff --git a/tests/data/teams.py b/tests/data/teams.py index 34c91b7..2d053ba 100644 --- a/tests/data/teams.py +++ b/tests/data/teams.py @@ -10,7 +10,7 @@ def team_summary( team_id: int = 1, slug: str = "justice-league", org_login: str = "github", - **kwargs: dict[str, Any], + **kwargs: Any, ) -> GithubTeamSummary: return { "id": team_id, @@ -34,7 +34,7 @@ def team( team_id: int = 1, organization: GithubOrgSummary | None = None, slug: str = "justice-league", - **kwargs: dict[str, Any], + **kwargs: Any, ) -> GithubTeam: org = organization if organization else GITHUB_ORG summary = team_summary(team_id=team_id, org_login=org["login"], slug=slug) diff --git a/tests/data/users.py b/tests/data/users.py index 7a7babc..759201f 100644 --- a/tests/data/users.py +++ b/tests/data/users.py @@ -8,7 +8,7 @@ def user( *, user_login: str = "octocat", user_id: int = 1, - **kwargs: dict[str, Any], + **kwargs: Any, ) -> GithubUser: return { diff --git a/tests/mocks/githubrest.py b/tests/mocks/githubrest.py index 43a57bb..e8bdb7f 100644 --- a/tests/mocks/githubrest.py +++ b/tests/mocks/githubrest.py @@ -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: dict[str, Any]): + def add_exception(self, *, exception: Exception, **matchers: Any): self.httpx_mock.add_exception(exception, **matchers) def add_response( @@ -55,7 +55,7 @@ def add_response( html: str | None = None, stream: Optional[any] = None, json: Optional[any] = None, - **matchers: dict[str, Any], + **matchers: Any, ): self.httpx_mock.add_response( status_code=status_code, @@ -69,12 +69,12 @@ def add_response( **matchers, ) - def all_orgs(self, **kwargs: dict[str, Any]) -> None: + def all_orgs(self, **kwargs: 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: dict[str, Any]) -> None: + def get_org(self, *, org_name: str, **kwargs: Any) -> None: self.add_response(url=f"{self.base_url}/orgs/{org_name}", **kwargs) def get_members_for_org( @@ -82,7 +82,7 @@ def get_members_for_org( *, org_name: str, role: OrgMemberRole | None = None, - **kwargs: dict[str, Any], + **kwargs: Any, ) -> None: actual_role = f"role={role}" if role else "" self.add_response( @@ -95,7 +95,7 @@ def get_repos_for_org( *, org_name: str, repo_type: OrgRepoType | None = None, - **kwargs: dict[str, Any], + **kwargs: Any, ): type_param = f"&type={repo_type}" if repo_type else "" self.add_response( @@ -103,13 +103,13 @@ def get_repos_for_org( **kwargs, ) - def list_teams_for_org(self, *, org_login: str, **kwargs: dict[str, Any]): + def list_teams_for_org(self, *, org_login: str, **kwargs: 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: dict[str, Any]): + def get_team(self, *, org_login: str, team_slug: str, **kwargs: Any): self.add_response( url=f"{self.base_url}/orgs/{org_login}/teams/{team_slug}", **kwargs ) @@ -119,22 +119,20 @@ def get_members_for_team( *, team_id: int, role: TeamMemberRole, - **kwargs: dict[str, Any], + **kwargs: 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: dict[str, Any] - ): + def get_repos_for_team(self, *, org_login: str, slug: str, **kwargs: 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: dict[str, Any]) -> None: + def all_repos(self, **kwargs: Any) -> None: self.add_response( url=f"{self.base_url}/repositories?per_page={self.per_page}", **kwargs ) @@ -144,16 +142,14 @@ def get_languages_for_repo( *, owner_login: str, repo_name: str, - **kwargs: dict[str, Any], + **kwargs: 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: dict[str, Any] - ): + def get_webhooks_for_repo(self, *, owner_login: str, repo_name: str, **kwargs: Any): self.add_response( url=f"{self.base_url}/repos/{owner_login}/{repo_name}/hooks?per_page={self.per_page}", **kwargs, @@ -165,14 +161,14 @@ def get_collaborators_for_repo( owner_login: str, repo_name: str, affiliation: CollaboratorAffiliation, - **kwargs: dict[str, Any], + **kwargs: 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: dict[str, Any]): + def all_users(self, **kwargs: Any): self.add_response( url=f"{self.base_url}/users?per_page={self.per_page}", **kwargs ) @@ -182,7 +178,7 @@ def get_repos_for_user( *, user_login: str, type_param: UserRepoType | None, - **kwargs: dict[str, Any], + **kwargs: Any, ): type_param = f"&type={type_param}" if type_param else "" self.add_response( @@ -190,7 +186,7 @@ def get_repos_for_user( **kwargs, ) - def get_enterprise_audit_logs(self, **kwargs: dict[str, Any]): + def get_enterprise_audit_logs(self, **kwargs: Any): url = ( f"{self.base_url}/enterprises/test-enterprise" f"/audit-log?per_page=100&phrase=action:protected_branch.create" From 5a42be9aa5587b250a0716a4664c4209e763b3da Mon Sep 17 00:00:00 2001 From: Jon Bristow Date: Thu, 20 Mar 2025 09:55:46 -0700 Subject: [PATCH 2/2] chore: fix rohith's username in codeowners --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 4cb5ff4..9d6b591 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -7,4 +7,4 @@ # the repo. Unless a later match takes precedence, # @global-owner1 and @global-owner2 will be requested for # review when someone opens a pull request. -* @jbristow @zprobst @ccloes @angelosantos4 @rreddy15 +* @jbristow @zprobst @ccloes @angelosantos4 @rreddy2