@@ -88,8 +88,8 @@ def check_user(user: User, password: str) -> bool:
8888 sleep (random .expovariate (10 ))
8989 return secrets .compare_digest (hashpass , target_hash_pass )
9090
91- def get_user (user : User ) -> UserInfo :
92- return user_info [ user ]
91+ def get_user (user : User ) -> Optional [ UserInfo ] :
92+ return user_info . get ( user )
9393
9494time_unit_cuts = [60 , 3600 , 3600 * 24 ] # type: List[int]
9595time_units = [(1 , 'second' ), (60 , 'minute' ), (3600 , 'hour' ), (24 * 3600 , 'day' )] # type: List[Tuple[int, str]]
@@ -100,11 +100,11 @@ def age(post: Post) -> str:
100100 units = seconds // divisor
101101 return '%d %s ago' % (units , unit + ('' if units == 1 else 's' ))
102102
103- def save ():
103+ def save () -> None :
104104 with open ('pubsub.pickle' , 'wb' ) as f :
105105 pickle .dump ([posts , user_posts , hashtag_index , following , followers , user_info ], f )
106106
107- def restore ():
107+ def restore () -> None :
108108 global posts , user_posts , hashtag_index , following , followers , user_info
109109 with open ('pubsub.pickle' , 'rb' ) as f :
110110 posts , user_posts , hashtag_index , following , followers , user_info = pickle .load (f )
0 commit comments