fix: Avoid using not-threadsafe arnings.catch_warning #1042
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📒 Description
warnings.catch_warnings
is not threadsafe. The main converter entry point raises warnings when a value can't be converted to the target types. It's up to the parsers to catch that warning per case and either raise ParserError or ignore them completely.When we are parsing unions of classes, we intentional trap those warnings in order to find the best candidate, but since catch_warnings is not thread safe, confusing warnings are logged 🤦
Move the logic to convert warnings to exception from the parsers to the parser utils and avoid using the
catch_warnings
altogether.Resolves #1041
🔗 What I've Done
💬 Comments
🛫 Checklist