Skip to content

Commit

Permalink
remove Client.get_constants
Browse files Browse the repository at this point in the history
  • Loading branch information
SharpBit committed Oct 7, 2024
1 parent 1a1bf30 commit 4b021a0
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 68 deletions.
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ All notable changes to this project will be documented in this file.
### Fixed
- Client actually uses session passed into parameters now instead of creating a new one anyways
- `UnexpectedError` now properly shows the returned text in the message
- The `use_cache` parameter now works for `get_constants`, `get_brawlers`, and the async client.
- The `use_cache` parameter now works for `get_brawlers` and the async client
### Removed
- No longer uses `asyncio.Lock` when prevent_ratelimit=True and is_async=True as that just imitates sync behavior
- Dropped support for Python 3.5, 3.6, 3.7, and 3.8.
- Removed the prevent_ratelimit option for the Client
- Dropped support for Python 3.5, 3.6, 3.7, and 3.8
- Removed `Client.get_constants` as the site that was hosting it is no longer running

## [4.1.1] - 10/31/21
### Fixed
Expand Down
3 changes: 2 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ Features
- Get a player profile and battlelog.
- Get a club and its members.
- Get the top 200 rankings for players, clubs, or a specific brawler.
- Get information about maps, brawlers, and more!
- Get information about all the brawlers in the game.
- Get information about the current event rotation!

Installation
~~~~~~~~~~~~
Expand Down
35 changes: 1 addition & 34 deletions brawlstats/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from cachetools import TTLCache

from .errors import Forbidden, NotFoundError, RateLimitError, ServerError, UnexpectedError
from .models import BattleLog, Brawlers, Club, Constants, EventRotation, Members, Player, Ranking
from .models import BattleLog, Brawlers, Club, EventRotation, Members, Player, Ranking
from .utils import API, bstag, typecasted

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -185,14 +185,6 @@ def _request(self, url, use_cache=True):
async def _aget_model(self, url, model, use_cache=True, key=None):
"""Method to turn the response data into a Model class for the async client."""
data = await self._arequest(url, use_cache=use_cache)

if model == Constants:
if key:
if data.get(key):
return model(self, data.get(key))
else:
raise KeyError(f'No such Constants key "{key}"')

return model(self, data)

def _get_model(self, url, model, use_cache=True, key=None):
Expand All @@ -202,14 +194,6 @@ def _get_model(self, url, model, use_cache=True, key=None):
return self._aget_model(url, model=model, use_cache=use_cache, key=key)

data = self._request(url, use_cache)

if model == Constants:
if key:
if data.get(key):
return model(self, data.get(key))
else:
raise KeyError(f'No such Constants key "{key}"')

return model(self, data)

@typecasted
Expand Down Expand Up @@ -354,23 +338,6 @@ def get_rankings(

return self._get_model(url, model=Ranking, use_cache=use_cache)

def get_constants(self, key: str=None, use_cache=True) -> Constants:
"""Gets Brawl Stars constants extracted from the app.
Parameters
----------
key : str, optional
Any key to get specific data, by default None
use_cache : bool, optional
Whether to use the internal 3 minutes cache, by default True
Returns
-------
Constants
Data containing some Brawl Stars constants.
"""
return self._get_model(self.api.CONSTANTS, model=Constants, key=key, use_cache=use_cache)

def get_brawlers(self, use_cache=True) -> Brawlers:
"""Gets available brawlers and information about them.
Expand Down
7 changes: 1 addition & 6 deletions brawlstats/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from .utils import bstag

__all__ = ['Player', 'Club', 'Members', 'Ranking', 'BattleLog', 'Constants', 'Brawlers', 'EventRotation']
__all__ = ['Player', 'Club', 'Members', 'Ranking', 'BattleLog', 'Brawlers', 'EventRotation']


class BaseBox:
Expand Down Expand Up @@ -135,11 +135,6 @@ def __repr__(self):
return '<Ranking object count={}>'.format(len(self))


class Constants(BaseBox):
"""Data containing some Brawl Stars constants."""
pass


class Brawlers(BaseBoxList):
"""A list of available brawlers and information about them."""

Expand Down
1 change: 0 additions & 1 deletion brawlstats/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ def __init__(self, base_url, version=1):
self.PROFILE = self.BASE + '/players'
self.CLUB = self.BASE + '/clubs'
self.RANKINGS = self.BASE + '/rankings'
self.CONSTANTS = 'https://fourjr.herokuapp.com/bs/constants'
self.BRAWLERS = self.BASE + '/brawlers'
self.EVENT_ROTATION = self.BASE + '/events/rotation'

Expand Down
3 changes: 0 additions & 3 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ Data Models
.. autoclass:: brawlstats.models.Members
:members:

.. autoclass:: brawlstats.models.Constants
:members:

.. autoclass:: brawlstats.models.Brawlers
:members:

Expand Down
4 changes: 2 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ Features
- Get a player profile and battlelog.
- Get a club and its members.
- Get the top 200 rankings for players, clubs, or a specific brawler.
- Get information about maps and more!
- Get information about current available brawlers.
- Get information about all the brawlers in the game.
- Get information about the current event rotation!

Installation
~~~~~~~~~~~~
Expand Down
9 changes: 0 additions & 9 deletions tests/test_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,6 @@ async def test_get_rankings(self):
with self.assertRaises(ValueError):
await self.client.get_rankings(ranking='brawlers', brawler='SharpBit')

async def test_get_constants(self):
constants = await self.client.get_constants()
self.assertIsInstance(constants, brawlstats.Constants)

maps = await self.client.get_constants('maps')
self.assertIsInstance(maps, brawlstats.Constants)

await self.assertAsyncRaises(KeyError, self.client.get_constants('invalid'))

async def test_get_brawlers(self):
brawlers = await self.client.get_brawlers()
self.assertIsInstance(brawlers, brawlstats.Brawlers)
Expand Down
9 changes: 0 additions & 9 deletions tests/test_blocking.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,6 @@ def test_get_rankings(self):
self.assertIsInstance(us_brawler_ranking, brawlstats.Ranking)
self.assertTrue(len(us_brawler_ranking) == 1)

def test_get_constants(self):
constants = self.client.get_constants()
self.assertIsInstance(constants, brawlstats.Constants)

maps = self.client.get_constants('maps')
self.assertIsInstance(maps, brawlstats.Constants)

self.assertRaises(KeyError, self.client.get_constants, 'invalid')

def test_get_brawlers(self):
brawlers = self.client.get_brawlers()
self.assertIsInstance(brawlers, brawlstats.Brawlers)
Expand Down

0 comments on commit 4b021a0

Please sign in to comment.