Skip to content

Commit

Permalink
ref(bot): cut dead Permission enum (#768)
Browse files Browse the repository at this point in the history
This is enum is unused now since #762.
  • Loading branch information
chdsbd authored Nov 26, 2021
1 parent 3df017c commit 852e345
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 22 deletions.
22 changes: 4 additions & 18 deletions bot/kodiak/queries/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,6 @@ class PRReviewAuthorSchema(BaseModel):
@dataclass
class PRReviewAuthor:
login: str
permission: Permission


class PRReviewSchema(BaseModel):
Expand Down Expand Up @@ -555,17 +554,6 @@ class CheckRun(BaseModel):
conclusion: Optional[CheckConclusionState]


class Permission(Enum):
"""
https://developer.github.com/v3/repos/collaborators/#review-a-users-permission-level
"""

ADMIN = "admin"
WRITE = "write"
READ = "read"
NONE = "none"


class TokenResponse(BaseModel):
token: str
expires_at: datetime
Expand Down Expand Up @@ -922,7 +910,7 @@ async def get_api_features(self) -> ApiFeatures | None:
)
return _api_features_cache

async def get_bot_reviews(self, *, reviews: List[PRReviewSchema]) -> List[PRReview]:
def get_bot_reviews(self, *, reviews: List[PRReviewSchema]) -> List[PRReview]:
bot_reviews: List[PRReview] = []
for review in reviews:
if not review.author:
Expand All @@ -935,9 +923,7 @@ async def get_bot_reviews(self, *, reviews: List[PRReviewSchema]) -> List[PRRevi
PRReview(
state=review.state,
createdAt=review.createdAt,
author=PRReviewAuthor(
login=review.author.login, permission=Permission.WRITE
),
author=PRReviewAuthor(login=review.author.login),
)
)

Expand Down Expand Up @@ -1068,8 +1054,8 @@ async def get_event_info(self, pr_number: int) -> Optional[EventInfoResponse]:
repo=repository, ref_name=pr.baseRefName
)

partial_reviews = get_reviews(pr=pull_request)
bot_reviews = await self.get_bot_reviews(reviews=partial_reviews)
all_reviews = get_reviews(pr=pull_request)
bot_reviews = self.get_bot_reviews(reviews=all_reviews)
return EventInfoResponse(
config=cfg.parsed,
config_str=cfg.text,
Expand Down
3 changes: 1 addition & 2 deletions bot/kodiak/test_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
MergeableState,
MergeStateStatus,
NodeListPushAllowance,
Permission,
PRReview,
PRReviewAuthor,
PRReviewRequest,
Expand Down Expand Up @@ -271,7 +270,7 @@ def create_review() -> PRReview:
return PRReview(
state=PRReviewState.APPROVED,
createdAt=datetime(2015, 5, 25),
author=PRReviewAuthor(login="ghost", permission=Permission.WRITE),
author=PRReviewAuthor(login="ghost"),
)


Expand Down
3 changes: 1 addition & 2 deletions bot/kodiak/test_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
MergeableState,
MergeStateStatus,
NodeListPushAllowance,
Permission,
PRReview,
PRReviewAuthor,
PRReviewRequest,
Expand Down Expand Up @@ -202,7 +201,7 @@ def block_event() -> EventInfoResponse:
PRReview(
createdAt=datetime.fromisoformat("2019-05-24T10:21:32+00:00"),
state=PRReviewState.APPROVED,
author=PRReviewAuthor(login="kodiakhq", permission=Permission.WRITE),
author=PRReviewAuthor(login="kodiakhq"),
),
],
status_contexts=[
Expand Down

0 comments on commit 852e345

Please sign in to comment.