4 ms·
Type annotations are just hints and aren't enforced at runtime. You can pass whatever you want into that function, and you can also create a union type with the
by heavyset_go 6y ago
Type annotations are just hints and aren't enforced at runtime. You can pass whatever you want into that function, and you can also create a union type with the Fraction if you want the annotations to match your application.
- pansa2 6y ago> You can pass whatever you want into that function Not really. Doing so won't cause an error at runtime, but it will produce an error when you run the type checker.
- musicale 6y agoYou seem to have removed the previous sentence which qualified the statement as "at runtime."
- pansa2 6y agoHow can I pass whatever I want into that function at runtime, while still satisfying the type checker?
- _flux 6y agoYou can use the Any type, or you can not annotate at all, though I'm not sure if the latter is something that passes some stricter modes of e.g. mypy.
- dragonwriter 6y ago> How can I pass whatever I want into that function at runtime, while still satisfying the type checker? Tell the type-checker to buzz-off by any number of means, including # type: ignore