Created
June 25, 2020 12:24
-
-
Save jugmac00/14e541fbc15cdd6b511e343faba29b00 to your computer and use it in GitHub Desktop.
converting the type comments in this module to annotations with com2ann breaks the code, cf. postponed evaluation of annotations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Optional | |
from typing import List | |
class Pizza: | |
def __init__(self, ingredients=None): | |
# type: (Optional[List[str]]) -> None | |
if ingredients is None: | |
self.ingredients = [] | |
else: | |
self.ingredients = ingredients | |
def __repr__(self): | |
# type: () -> str | |
return "This is a Pizza with %s on it" % " ".join(self.ingredients) | |
@classmethod | |
def pizza_salami(cls): | |
# type: () -> Pizza | |
return cls(ingredients=["Salami", "Cheese", "Onions"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment