#!/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()
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)