Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref(bot): cut dead Permission enum #768

Merged
merged 5 commits into from
Nov 26, 2021
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
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