Skip to content

Commit

Permalink
chore: wrap commit lists into a NiceReprList
Browse files Browse the repository at this point in the history
  • Loading branch information
phil65 committed Nov 16, 2024
1 parent 6d4fbdd commit 9ba6d0d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/githarbor/core/datatypes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from __future__ import annotations

import reprlib
from typing import TypeVar


T = TypeVar("T")


class NiceReprList(list[T]):
def __repr__(self):
return reprlib.repr(list(self))
6 changes: 4 additions & 2 deletions src/githarbor/core/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from typing import TYPE_CHECKING, Any, Literal

from githarbor.core.base import BaseRepository
from githarbor.core.datatypes import NiceReprList
from githarbor.exceptions import ResourceNotFoundError


Expand Down Expand Up @@ -138,7 +139,7 @@ def list_commits(
author: str | None = None,
path: str | None = None,
max_results: int | None = None,
) -> list[Commit]:
) -> NiceReprList[Commit]:
"""List commits with optional filters.
Args:
Expand All @@ -152,14 +153,15 @@ def list_commits(
Returns:
List of commits.
"""
return self._repository.list_commits(
commits = self._repository.list_commits(
branch=branch,
since=since,
until=until,
author=author,
path=path,
max_results=max_results,
)
return NiceReprList(commits)

def get_workflow(self, workflow_id: str) -> Workflow:
"""Get information about a specific workflow.
Expand Down

0 comments on commit 9ba6d0d

Please sign in to comment.