Skip to content

Commit

Permalink
Add default None values to optional fields
Browse files Browse the repository at this point in the history
  • Loading branch information
tianyizheng02 committed Aug 18, 2024
1 parent 1e18ead commit f28fdc4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions pittapi/gym.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@

class Gym(NamedTuple):
name: str
last_updated: str | None
current_count: int | None
percent_full: int | None
last_updated: str | None = None
current_count: int | None = None
percent_full: int | None = None

@classmethod
def from_text(cls, text: str) -> Gym:
info = text.split("|")
name = info[0]
if len(info) < 4:
return cls(name=name, last_updated=None, current_count=None, percent_full=None)
return cls(name=name)
count = int(info[2][12:])
date_time = info[3][9:]
try:
Expand Down
2 changes: 1 addition & 1 deletion tests/gym_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_fetch_gym_info(self):
current_count=50,
percent_full=0,
),
gym.Gym(name="Bellefield Hall: Court & Dance Studio", last_updated=None, current_count=None, percent_full=None),
gym.Gym(name="Bellefield Hall: Court & Dance Studio"),
gym.Gym(name="Trees Hall: Fitness Center", last_updated="07/09/2024 09:05 AM", current_count=70, percent_full=58),
gym.Gym(name="Trees Hall: Courts", last_updated="07/09/2024 09:05 AM", current_count=20, percent_full=33),
gym.Gym(
Expand Down

0 comments on commit f28fdc4

Please sign in to comment.