Skip to content

Instantly share code, notes, and snippets.

@saml
Created July 18, 2019 17:20
Show Gist options
  • Save saml/8f7ca0f5845760fee77c1470f183a2ce to your computer and use it in GitHub Desktop.
Save saml/8f7ca0f5845760fee77c1470f183a2ce to your computer and use it in GitHub Desktop.
from typing import Optional
a: Optional[str] = None
def init():
global a
a = 'abc'
def g() -> str: # supposed to be called after calling init()
return a
# $ mypy a.py
# a.py:8: error: Incompatible return value type (got "Optional[str]", expected "str")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment