Skip to content

Bug: _pr_number_from_commit() can return None, but it is annotated as an int #4399

@Peopl3s

Description

@Peopl3s

Description

def _pr_number_from_commit(comp: Comp) -> int:

def _pr_number_from_commit(comp: Comp) -> int: <-------------------------------------HERE
    # this is an ugly hack, but it appears to actually be the most reliably way to
    # extract the most "reliable" way to extract the info we want from GH ¯\_(ツ)_/¯
    message_head = comp.commit.message.split("\n\n")[0]
    match = re.search(r"\(#(\d+)\)$", message_head)
    if not match:
        print(f"Could not find PR number in {message_head}")  # noqa: T201
    return int(match[1]) if match else None <--------------------------------------------HERE

What to do: change the signature to -> int | None and remove implicit conversions in the places of use (filter(None, ...) is currently used, but the annotations are misleading).

URL to code causing the issue

No response

MCVE

Steps to reproduce

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Screenshots

No response

Logs


Litestar Version

2.17.0

Platform

  • Linux
  • Mac
  • Windows
  • Other (Please specify in the description above)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug 🐛This is something that is not working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions