replace incorrect 'Pattern' typehint with 'str' #121
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.
typing.Pattern is a deprecated alias since version 3.9 as per: https://docs.python.org/3/library/typing.html#typing.Pattern that was supposed to represent the return type of re.compile().
It was used in the definitions of IMAP4ClientProtocol.wait and IMAP4.list
In IMAP4.list I found out through manual testing that it expects a Literal, even though my linter bugged me about it due to the Pattern type hint.
In IMAP4ClientProtocol.wait the first line runs re.compile on the parameter that is type-hinted as Pattern, therefore it must also take a Literal and not a Pattern.
I think it would reduce confusion when using the module if we replaced these type hints with the correct types. Having them there doesn't necessarily make it so the code doesn't run, but it definitely took me some time to look and find out what was wrong that could be avoided by future users of the library.
Thanks & kind regards