Do not check | in type hints in WPS226 #2495
Merged
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.
I have made things!
In my project I use a lot of new-style annotations -
Type1 | Type2
instead ofUnion[Type1, Type2]
provided by Python 3.10. To get these annotations work on previous Python versions (e.g. 3.7) I usefrom __future__ import annotations
, which converts all type hints to strings, so it is actually stored in__annotations__
like"Type1 | Type2"
.If module contains a lot of optional annotations, such as:
and so on, WPS226 starts to fail:
In this PR I've added
|
literal to list of ignored strings which should fix the issue.Checklist
CHANGELOG.md
Related issues
馃檹 Please, if you or your company is finding wemake-python-styleguide valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/wemake-python-styleguide. As a thank you, your profile/company logo will be added to our main README which receives hundreds of unique visitors per day.