Skip to content

improve(asserts): clarify bare Ellipsis usage in assert_shape error - #464

Open
erensh27 wants to merge 1 commit into
google-deepmind:mainfrom
erensh27:fix/assert-shape-ellipsis-message
Open

improve(asserts): clarify bare Ellipsis usage in assert_shape error#464
erensh27 wants to merge 1 commit into
google-deepmind:mainfrom
erensh27:fix/assert-shape-ellipsis-message

Conversation

@erensh27

@erensh27 erensh27 commented Aug 9, 2026

Copy link
Copy Markdown

Improvement for #437: a bare Ellipsis passed as expected_shapes now gets a dedicated hint in the error message, instead of the generic type complaint which made users think ... was unsupported.

assert_shape(x, ...)
# before: AssertionError: ... expected shapes should be a list or tuple of ints, got Ellipsis.
# after:  AssertionError: ... got Ellipsis. For a wildcard shape, pass a tuple, e.g. (...,) instead of a bare Ellipsis (...).

Added a regression test (test_bare_ellipsis_message_suggests_tuple_form) in asserts_test.py. No other behavior changed: (...,) still works as before.

Passing  directly to assert_shape raised
'expected shapes should be a list or tuple of ints, got Ellipsis',
which implies a type mistake even though  is a valid wildcard
shape. Special-case Ellipsis in the error message and point users at
the  form.
@google-cla

google-cla Bot commented Aug 9, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant