Skip to content

Add instancecheck_str__ to _JustMeta for custom beartype error messages#593

Open
Aniketsy wants to merge 4 commits into
jorenham:masterfrom
Aniketsy:fix-591
Open

Add instancecheck_str__ to _JustMeta for custom beartype error messages#593
Aniketsy wants to merge 4 commits into
jorenham:masterfrom
Aniketsy:fix-591

Conversation

@Aniketsy

Copy link
Copy Markdown
Contributor

fixes #591

x-ref: Farama-Foundation/Gymnasium#1573 (comment)

followed the comment, it was quite big, funny and with good explanation (i read it twice to fully understand 😀 )

  • i haven't added unit test for this yet .

@github-actions

github-actions Bot commented May 11, 2026

Copy link
Copy Markdown
Contributor

mypy_primer results

✅ No ecosystem changes detected

Comment thread optype/_core/_just.py

@jorenham jorenham left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how, but we should also figure out a way to test that this actually works.

@Aniketsy

Copy link
Copy Markdown
Contributor Author

I'm not sure how, but we should also figure out a way to test that this actually works.

hmm, i'll look into this to test

@Aniketsy

Copy link
Copy Markdown
Contributor Author

should we add ignore comment to fix these ci-fails ?

@jorenham

Copy link
Copy Markdown
Owner

should we add ignore comment to fix these ci-fails ?

The error is intentional, so yes.

Comment thread tests/core/test_just.py Outdated
Signed-off-by: Aniket <148300120+Aniketsy@users.noreply.github.com>
Comment thread tests/core/test_just.py Outdated
Signed-off-by: Aniket <148300120+Aniketsy@users.noreply.github.com>
@Aniketsy

Copy link
Copy Markdown
Contributor Author

Any thoughts on this :)

Comment thread tests/core/test_just.py

with pytest.raises(
BeartypeCallHintParamViolation,
match="subclasses are not accepted",

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we might as well test the entire exception message

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Customize Just* beartype error messages using __instancecheck_str__

2 participants