Can Protocol express conditional sorted() requirements without Any? #2124
Unanswered
hunterhogan
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
In the function
updateExtendPolishDictionaryLists, for the elements of thelist, is it possible to use a type hint more specific thanAny?I would like to ask a better question, but I am struggling to discriminate the important concepts from everything else going on in the function.
I have essentially no experience with
Protocol, but I've been using this prototype for a short while. On the other hand, I have literally only used it with non-negativeint--that are less than 64.(This package requires <= Python 3.12:)
If possible, I would like to improve the type hints in
updateExtendPolishDictionaryLists, but I can't find the right combination. If I changeePluribusUnumfromdict[..., list[...]]toSequence[...], then.extendcomplains about not being alist, and I don't know how to fix that, even though I suspect it is easy.I've tried different combinations of Mapping, Sequence, and using the Union operator. This answer is thorough and clear, and I almost understand it, but I can't figure out if it is or isn't relevant to my goal.
Similarly, I think I understand at least half of this discussion about
SupportsRichComparison, and maybe it means I can't be more specific thanAny, but I'm not sure.I tried this silliness:
It doesn't work, of course, because 'Declaration "ePluribusUnum" is obscured by a declaration of the same name.'
This issue is not critical, which is why I hope it is a good way for me to learn more: less pressure.
This package requires <= Python 3.11:
The two diagnostic messages
Beta Was this translation helpful? Give feedback.
All reactions