Skip to content

get_team_events() fails with UserWarning: Invalid query: if limit is not specified in the parametersΒ #393

@INeedCaffeine

Description

@INeedCaffeine

When I run this simple script at the bottom I get an error you see below when I do not pass in a value for limit:

(.venv) D:\Workspace\Statbotics>python test_get_team_events.py
----------------------------------------------
get_team_events(team=254, limit=5)------------
[{'country': 'USA',
  'district': None,
**...[Edited out for brevity]...**
  'team': 254,
  'team_name': 'The Cheesy Poofs',
  'time': 1046926800,
  'type': 'regional',
  'week': 1,
  'year': 2003}]
----------------------------------------------
get_team_events(team=254)---------------------
Traceback (most recent call last):
  File "D:\Workspace\Statbotics\test_get_team_events.py", line 26, in <module>
    pprint.pprint(sb.get_team_events(team=254))
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Projects\TestMongo\.venv\Lib\site-packages\statbotics\main.py", line 439, in get_team_events
    return self._get_plural(url, fields)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Projects\TestMongo\.venv\Lib\site-packages\statbotics\main.py", line 78, in _get_plural
    return self._get_plural(url, fields, retry=retry + 1)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Projects\TestMongo\.venv\Lib\site-packages\statbotics\main.py", line 78, in _get_plural
    return self._get_plural(url, fields, retry=retry + 1)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Projects\TestMongo\.venv\Lib\site-packages\statbotics\main.py", line 79, in _get_plural
    raise UserWarning("Invalid query: " + url)
UserWarning: Invalid query: /team_events?limit=0&offset=0&team=254&metric=year&ascending=True

This is the script:

import pprint
import statbotics

# Create a Statbotics object
sb = statbotics.Statbotics()

# Get the stats for Team 254 but limit it to 5
print("----------------------------------------------")
print("get_team_events(team=254, limit=5)------------")
pprint.pprint(sb.get_team_events(team=254, limit=5))

# Get the stats for Team 254 with NO limit specified
print("----------------------------------------------")
print("get_team_events(team=254)---------------------")
pprint.pprint(sb.get_team_events(team=254))

Environment:
Win11 running Python 3.11.7 with statbotics 3.0.0 installed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions