Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding type annotation for the scoreboard method #467

Merged
merged 3 commits into from Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions espn_api/football/league.py
Expand Up @@ -19,7 +19,7 @@ class League(BaseLeague):
'''Creates a League instance for Public/Private ESPN league'''
def __init__(self, league_id: int, year: int, espn_s2=None, swid=None, fetch_league=True, debug=False):
super().__init__(league_id=league_id, year=year, sport='nfl', espn_s2=espn_s2, swid=swid, debug=debug)

if fetch_league:
self.fetch_league()

Expand Down Expand Up @@ -185,9 +185,9 @@ def scoreboard(self, week: int = None) -> List[Matchup]:

for team in self.teams:
for matchup in matchups:
if matchup.home_team == team.team_id:
if matchup._home_team_id == team.team_id:
matchup.home_team = team
elif matchup.away_team == team.team_id:
elif matchup._away_team_id == team.team_id:
matchup.away_team = team

return matchups
Expand Down Expand Up @@ -296,7 +296,7 @@ def player_info(self, name: str = None, playerId: Union[int, list] = None) -> Un
return Player(data['players'][0], self.year)
if len(data['players']) > 1:
return [Player(player, self.year) for player in data['players']]

def message_board(self, msg_types: List[str] = None):
''' Returns a list of league messages'''
data = self.espn_request.get_league_message_board(msg_types)
Expand Down
8 changes: 6 additions & 2 deletions espn_api/football/matchup.py
@@ -1,10 +1,14 @@
from .team import Team

class Matchup(object):
'''Creates Matchup instance'''
def __init__(self, data):
self.matchup_type = data.get('playoffTierType', 'NONE')
self.is_playoff = self.matchup_type != 'NONE'
(self.home_team, self.home_score) = self._fetch_matchup_info(data, 'home')
(self.away_team, self.away_score) = self._fetch_matchup_info(data, 'away')
(self._home_team_id, self.home_score) = self._fetch_matchup_info(data, 'home')
(self._away_team_id, self.away_score) = self._fetch_matchup_info(data, 'away')
self.home_team: Team
self.away_team: Team

def __repr__(self):
return f'Matchup({self.home_team}, {self.away_team})'
Expand Down