Fix some typing bits

This commit is contained in:
Dan Buch 2021-01-10 12:43:54 -05:00
parent ffc3934487
commit db6d5ad880
Signed by: meatballhat
GPG Key ID: 9685130D8B763EA7

View File

@ -3,7 +3,13 @@ import typing
def main() -> int:
checked = [passport.is_valid() for passport in _read_passports(sys.stdin)]
checked = []
for passport in _read_passports(sys.stdin):
if passport is None:
checked.append(False)
continue
checked.append(passport.is_valid())
print(f"total={len(checked)} valid={checked.count(True)}")
return 0
@ -88,8 +94,8 @@ class Passport:
def _read_passports(
instream: typing.BinaryIO,
) -> typing.Generator[None, None, Passport]:
instream: typing.TextIO,
) -> typing.Generator[typing.Optional[Passport], None, None]:
cur = Passport()
for i, line in enumerate(instream):