Dec-14-2023, 08:39 PM
I am using type hints as an experiment to see the pros and cons. I am also using PyPy a an experiment with static type checking.
Here's an inconvenient situation.
Say variable x can be None | list[int].
And say that I know based on an earlier conditional that x is not None.
But if I try to access x[1] I get a type error because the static type checker thinkgs it might be None.
What's the pythonic way to handle this?
Thanks!
Here's an inconvenient situation.
Say variable x can be None | list[int].
And say that I know based on an earlier conditional that x is not None.
But if I try to access x[1] I get a type error because the static type checker thinkgs it might be None.
What's the pythonic way to handle this?
Thanks!