Skip to content

Commit

Permalink
Fixup typing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
wjdp committed Jul 28, 2023
1 parent 00732b9 commit 542598a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/lumina/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def __init__(self, optional: bool = False):
self.optional = optional
super().__init__(auto_error=False)

async def __call__(self, request: Request) -> AuthenticatedToken | None:
async def __call__(self, request: Request) -> AuthenticatedToken | None: # type: ignore
credentials = await super(JWTBearer, self).__call__(request)
if credentials:
try:
Expand Down
15 changes: 9 additions & 6 deletions src/lumina/github/submissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@ def get_body_for_submission(
):
assert not (submitter and member), "Cannot have both submitter and member"

repo_file_path = get_content_repo_path(target_type, target_id)
repo_file_url = get_content_repo_file_url(repo_file_path)
if member:
submitter = f"[{member.name}]({get_submitter_public_link(member.pk)})"
elif submitter:
submitter = submitter.name
else:
raise ValueError("Must have submitter or member")

submitter = (
f"[{member.name}]({get_submitter_public_link(member.pk)})"
if member
else submitter.name
repo_file_path = get_content_repo_path(target_type, target_id)
repo_file_url = (
get_content_repo_file_url(repo_file_path) if repo_file_path else None
)

return f"""
Expand Down
2 changes: 1 addition & 1 deletion src/lumina/github/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
log = logging.getLogger(__name__)


def get_content_repo_path(target_type: str, target_id: str) -> str:
def get_content_repo_path(target_type: str, target_id: str) -> str | None:
if target_type == "show":
return f"_shows/{target_id}.md"
return None
Expand Down
9 changes: 8 additions & 1 deletion src/lumina/schema/submissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ class GenericSubmissionRequest(BaseSubmissionRequest):
subject: str | None = FIELD_SUBJECT
message: str = FIELD_MESSAGE

def get_submitter_model(self, member: MemberModel | None) -> SubmitterModel:
if member:
return member.to_submitter()
if self.submitter:
return self.submitter.to_model()
raise ValueError("You either need a submitter or a member to make a submission")

def to_model(
self,
*,
Expand All @@ -106,7 +113,7 @@ def to_model(
created_at=dates.now(),
subject=self.subject,
message=self.message,
submitter=member.to_submitter() if member else self.submitter.to_model(),
submitter=self.get_submitter_model(member),
github_issue=lumina.github.submissions.make_issue_model(github_issue),
)

Expand Down

0 comments on commit 542598a

Please sign in to comment.