zero-sum-seattle / python-mlb-statsapi

Python Wrapper for the MLB's Official Stats API
MIT License
48 stars 11 forks source link

Missing Positional Argument for ScheduleGames.__init__ #210

Closed pferreira8 closed 5 months ago

pferreira8 commented 6 months ago

I have some code that was working last I checked a few months ago and no longer the case.

    def get_season_games(self, _season :mlb.models.seasons.Season):
        st, end = _season.seasonstartdate, _season.seasonenddate # extract start and end dates from season object
        # print(st, end)
        # return self.api.get_game_ids(sport_id=1, start_date=st, end_date=datetime.date.today().isoformat())
        return self.api.get_scheduled_games_by_date(start_date=st, end_date=end)

self.api is set = mlb.Mlb()

TypeError: ScheduleGames.init() missing 1 required positional argument: 'ifnecessarydescription'

mlwilliams217 commented 6 months ago

Ran into the same problem. Just to help debug, I'm narrowed down the exact date where the error occurs, which is 2024-05-14. This works

  # Initialize API object
  mlb = mlbstatsapi.Mlb()

  # Get games
  all_games = mlb.get_scheduled_games_by_date(
      start_date="2024-05-01", end_date=""2024-05-13", gameTypes="R"
  )

And this also works

  # Initialize API object
  mlb = mlbstatsapi.Mlb()

  # Get games
  all_games = mlb.get_scheduled_games_by_date(
      start_date="2024-05-15", end_date=""2024-05-24", gameTypes="R"
  )

However passing a date range that includes "2024-05-14" in it will result in the error referred to above. I assume it's from some sort of weird data for a game that day (I see there's a postponed game then).

KCNilssen commented 6 months ago

Looks like the MLB API was updated recently. Thats why it's only throwing that "missing required positional argument' TypeError after a certain date!

I'll get on fixing that as soon as I can. Thanks for the heads up guys!

KCNilssen commented 5 months ago

pferreira8 and mlwilliams217, Apologies for the delay, some things came up IRL but everything should be working and published. Update and give it a go

pferreira8 commented 5 months ago

pferreira8 and mlwilliams217, Apologies for the delay, some things came up IRL but everything should be working and published. Update and give it a go

great to hear!