Join Nostr
2026-08-12 20:59:20 UTC

Alice Averlong🏳️‍⚧️ on Nostr: ugh I haven't done enough python typing (stuck on 2.x for too long) to know how to do ...

ugh I haven't done enough python typing (stuck on 2.x for too long) to know how to do this. I have this code:

def blah(arg: str):
...
def main(arg: str|None):
if arg is None:
raise SomeError
blah(arg)

this code should work at runtime, but the problem is that I'm running this through some typechecking linter (ty) which is (rightly) pointing out that blah doesn't take a "str|None" type, it takes a "str". But it doesn't know I ruled out the None.

How do I fix? like, cast arg to str