Lowest common denominator of set and fronzenset? #9591
-
How to type a function argument so that both set and frozenset can be passed?
(To be fair this is really a form of "repeatable [unordered] iterable" for which there's no good type hint). |
Beta Was this translation helpful? Give feedback.
Answered by
Azureblade3808
Dec 18, 2024
Replies: 2 comments 2 replies
-
I'm not sure I understand your question. Would a simple union type meet your needs? def func(x: set[Any] | frozenset[Any]):
pass |
Beta Was this translation helpful? Give feedback.
2 replies
-
from collections.abc import Set
def func(x: Set[int]): ...
func({0})
func(frozenset({0})) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
dimaqq
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
collections.abc.Set
(also known astyping.AbstractSet
) may suit your need.