Skip to content

Instantly share code, notes, and snippets.

@jugmac00
Created June 25, 2020 12:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jugmac00/14e541fbc15cdd6b511e343faba29b00 to your computer and use it in GitHub Desktop.
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
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