Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

catch now raises typeerror on async handler #69

Merged
merged 5 commits into from
Jul 12, 2023

Conversation

jakkdl
Copy link
Contributor

@jakkdl jakkdl commented Jul 12, 2023

@Zac-HD
Fixes #66

I'm not entirely sure about the error message - which ones of exc, excgroup, matched and/or exc_types should be printed, and should we print the str, repr, or __name__.

Currently it looks like:

E   TypeError: Error trying to handle ExceptionGroup('', [TypeError('second argument (exceptions) must be a sequence')]) with <function test_async_handler.<locals>.handler at 0x7f319f598b80>. Exception handler must be a sync function

which certainly isn't the prettiest.

@coveralls
Copy link

coveralls commented Jul 12, 2023

Pull Request Test Coverage Report for Build 5533655265

  • 6 of 6 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+2.5%) to 98.641%

Totals Coverage Status
Change from base Build 5513148018: 2.5%
Covered Lines: 508
Relevant Lines: 515

💛 - Coveralls

tests/test_catch.py Outdated Show resolved Hide resolved
src/exceptiongroup/_catch.py Outdated Show resolved Hide resolved
CHANGES.rst Outdated Show resolved Hide resolved
@jakkdl
Copy link
Contributor Author

jakkdl commented Jul 12, 2023

Hm, I'm utterly failing to suppress the RuntimeWarning about handler not being awaited in the test when at the same checking for pytest.raises. I've tried pretty much all variants in https://docs.pytest.org/en/7.1.x/how-to/capture-warnings.html and putting the guards at different places in the test case but it seems like pytest.raises overrides warnings.catch_warnings() / pytest.warns() / recwarn

tests/test_catch.py Outdated Show resolved Hide resolved
Co-authored-by: Alex Grönholm <alex.gronholm@nextday.fi>
@jakkdl
Copy link
Contributor Author

jakkdl commented Jul 12, 2023

sorry for the force-pushing, I pushed ignoring the RuntimeError just before I saw your change suggestion which fixed that, so I rebased away my commit.

@jakkdl jakkdl requested a review from agronholm July 12, 2023 15:14
CHANGES.rst Outdated Show resolved Hide resolved
@agronholm agronholm merged commit 1d604fb into agronholm:main Jul 12, 2023
10 checks passed
@agronholm
Copy link
Owner

Thanks!

@jakkdl
Copy link
Contributor Author

jakkdl commented Jul 12, 2023

My pleasure! 🚀

@jakkdl jakkdl deleted the typeerror_on_async branch July 12, 2023 22:14
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.

with exceptiongroup.catch({Exception: async_fn}): is a tempting and silent footgun
3 participants