4 ms·
Whats the expected error in the example you gave? That x can't be none because it was received as a str?
by parhamn 1y ago
Whats the expected error in the example you gave? That x can't be none because it was received as a str?
- boxed 1y agoOr that x is unused?
- pawelkobojek 1y agoExactly - something along the lines of "Statement is unreachable".
- robertlagrant 1y agoYes, exactly. x would have to be str | None to be reachable.
- wiz21c 1y agoisn't it perfectly valid to pass None to that function ? It's not like python enforces types at runtime nor at compile time. Right ?
- Austizzle 1y agoIt's not valid from a typing perspective, but python will let you. If you want to disregard types though then none of this matters anyway and you won't get much benefit from these tools
- yesb 1y agoSure, it's valid python to do that. By that logic you could also pass an int. But the context of this post is that you're using a static type checker.