Towards mypy cleanliness.
[kiosk.git] / grab_bag.py
index 1620da209c298820fe164f56bc02f4a2520dca5b..798ebcfb154b58c3fdbf9588bcc01bc4b69d140a 100644 (file)
@@ -1,12 +1,12 @@
 #!/usr/bin/env python3
 
 import random
-from typing import Iterable, List
+from typing import Iterable, List, Optional, Set
 
 
 class grab_bag(object):
     def __init__(self) -> None:
-        self.contents = set()
+        self.contents: Set[str] = set()
 
     def clear(self) -> None:
         self.contents.clear()
@@ -19,7 +19,7 @@ class grab_bag(object):
         for x in collection:
             self.add(x)
 
-    def subset(self, count: int) -> List[str]:
+    def subset(self, count: int) -> Optional[List[str]]:
         if len(self.contents) < count:
             return None
         subset = random.sample(self.contents, count)