Replies: 1 comment
-
I'm not completely sure what you're trying to do, but I have two general ideas to satisfy the type checker:
# approach 1
if field is not None:
print(field) or # approach 2
if field is None:
raise Exception
print(field) In either case the checker should know that
def field_is_not_optional(self, field: int) -> None:
print(field) This is a better approach anyway if |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hey everyone, I have the following piece of code:
Is there a way to statically say that in the
field_is_not_optional
methodself.parent.field
will never be None?Beta Was this translation helpful? Give feedback.
All reactions