Skip to content

Commit 8a301c6

Browse files
committed
slightly nicer fix for mypy
1 parent 6ef6519 commit 8a301c6

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

intbot/core/integrations/github.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,12 @@ def github_object(self) -> GithubDraftIssue | GithubIssue:
129129
content = self.extra["content"]
130130
typename = content.pop("__typename")
131131

132-
# The typing here is only to make mypy happy. If you have a better idea
133-
# how to do it, please fix :)
134-
CONTENT_TYPE_MAP: dict[str, type[GithubIssue] | type[GithubDraftIssue]] = {
135-
"Issue": GithubIssue,
136-
"DraftIssue": GithubDraftIssue,
137-
}
138-
139-
obj = CONTENT_TYPE_MAP[typename].model_validate(content)
140-
return obj
132+
if typename == "Issue":
133+
return GithubIssue.model_validate(content)
134+
elif typename == "DraftIssue":
135+
return GithubDraftIssue.model_validate(content)
136+
else:
137+
raise ValueError("Other types are not supported")
141138

142139
def get_project(self) -> GithubProject:
143140
return GithubProject.model_validate(self.extra["project"])

0 commit comments

Comments
 (0)