-
Hello, I am creating a Python package that uses bidict. I'm wondering what type hinting I should assign to this data. b: bidict[str, str] = bidict(
{
"H": "hydrogen",
"C": "carbon"
}
) Is the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Yes, that is correct. You can use # demo.py
from bidict import bidict
b = bidict({"H": "hydrogen", "C": "carbon"})
reveal_type(b) $ mypy demo.py
demo.py:4: note: Revealed type is "bidict._bidict.bidict[builtins.str*, builtins.str*]" What package are you creating that uses bidict? |
Beta Was this translation helpful? Give feedback.
-
My personal Python package uses bidict for hexadecimal conversion. You can see the work-in-progress code here if you're interested. Either way, thanks for the confirmation! :D |
Beta Was this translation helpful? Give feedback.
Yes, that is correct. You can use
reveal_type
to have mypy confirm this for you:What package are you creating that uses bidict?