Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

assert_never raises different exception than documented #1857

Closed
@EliahKagan

Description

@EliahKagan

git.types.assert_never is documented to raiseAssertionError ifraise_error isTrue andexc isNone:

If raise_error is True, will also raise AssertionError or the Exception passed to exc.

But it actually raisesValueError in this situation, its full implementation being:

ifraise_error:
ifexcisNone:
raiseValueError(f"An unhandled Literal ({inp}) in an if/else chain was found")
else:
raiseexc

For comparison. there is anassert_never function in Python'styping module since 3.11 (and intyping_extensions). This function is similar but only has one parameter--which the first parameter ofgit.types.assert_never corresponds to--and it documentsthat it raises an exception if called at runtime, but does not document the type of exception raised. At least currently in Python 3.12,it raisesAssertionError.

The GitPython function is a public member ofgit.types, and it is used internally in GitPython. I don't know if the docstring should be fixed to describe the existing behavior, or if that behavior should itself be considered the bug here and changed to match the docstring.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp