-
Notifications
You must be signed in to change notification settings - Fork 2
Update to 1.3.0 to work in 2025 #4
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
base: master
Are you sure you want to change the base?
Conversation
…ion if player hasnt any game history;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request updates the brawlpy library to version 1.3.0 with improvements focused on modern async patterns, code formatting consistency, and documentation. The main enhancement is adding async context manager support to the Client class for better session lifecycle management.
Changes:
- Added async context manager (
__aenter__and__aexit__) methods to Client class for proper session management - Standardized code formatting by replacing single quotes with double quotes and improving code consistency
- Updated examples and README to demonstrate context manager usage
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| setup.py | Reformatted with double quotes and improved spacing consistency |
| examples/player.py | Updated to use async context manager pattern |
| examples/club.py | Updated to use async context manager pattern |
| brawlpy/utils.py | Improved formatting and updated imports |
| brawlpy/objects.py | Reformatted with consistent spacing and removed nameColor parameter from Player |
| brawlpy/main.py | Added context manager support, refactored session management, improved error handling |
| brawlpy/icons.py | Standardized dictionary formatting with double quotes |
| brawlpy/errors.py | Reformatted with double quotes for consistency |
| brawlpy/init.py | Replaced wildcard imports with explicit imports and updated version to 1.3.0 |
| brawlpy/API.py | Removed unused imports and reformatted |
| README.md | Updated documentation to show context manager usage and corrected repository URL |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Pl = Player( | ||
| player["name"], | ||
| player["tag"], | ||
| player["icon"]["id"], | ||
| player["trophies"], | ||
| player["expLevel"], | ||
| player["expPoints"], | ||
| cl, | ||
| player["highestTrophies"], | ||
| player["soloVictories"], | ||
| player["duoVictories"], | ||
| player["3vs3Victories"], | ||
| player["bestRoboRumbleTime"], | ||
| player["bestTimeAsBigBrawler"], | ||
| brrs, | ||
| ) |
Copilot
AI
Jan 18, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Player object instantiation is missing the battleLog parameter. The Player class constructor expects battleLog as the last parameter, but this code doesn't provide it. The old code had a call to get_battle_log that was removed but the parameter was never added here. This will cause a TypeError when creating a Player object.
| def __init__(self, url, code, text): | ||
| self.code = code | ||
| self.url = url | ||
| self.message = f'An unexpected error has occured.\n{text}' | ||
| self.message = f"An unexpected error has occured.\n{text}" | ||
| super().__init__(self.code, self.message) |
Copilot
AI
Jan 18, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The UnexpectedError constructor signature has inconsistent parameter order. The init method defines parameters as (url, code, text), but all call sites in main.py pass them as (status, url, ""). This will cause url to be assigned to code and "" to be assigned to url, breaking error reporting.
| url="https://github.com/PyStarr/BrawlPy", | ||
| long_description=long_description, | ||
| long_description_content_type="text/markdown", | ||
| download_url="https://github.com/PyStarr/BrawlPy/archive/v1.2.5.tar.gz", |
Copilot
AI
Jan 18, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The download_url still references version "1.2.5" in the archive URL, but should be updated to "1.3.0" to match the new version number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot open a new pull request to apply changes based on this feedback
|
|
||
|
|
||
| class UnexpectedError(Errors): | ||
| """Raised if an unknown error has occured.""" |
Copilot
AI
Jan 18, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spelling error: "occured" should be "occurred" (double 'r').
| rankgs.append( | ||
| BrawlerRanking( | ||
| "", | ||
| each["tag"], | ||
| each["name"], | ||
| each["nameColor"], | ||
| each["icon"]["id"], | ||
| each["trophies"], | ||
| each["rank"], | ||
| cl, | ||
| ) | ||
| ) |
Copilot
AI
Jan 18, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The BrawlerRanking constructor is being called with an empty string as the first parameter for 'brawler'. According to the BrawlerRanking class definition, the first parameter should be the brawler name or identifier, not an empty string. The API response should contain brawler information that needs to be extracted and passed here.
| def __init__(self,code,countryCode = None): | ||
| def __init__(self, code, countryCode=None): | ||
| self.code = code | ||
| if id: |
Copilot
AI
Jan 18, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition uses 'id' instead of 'countryCode'. This is a copy-paste error from the BrawlerNotFound exception above. It should check 'if countryCode:' to properly set the error message.
| if id: | |
| if countryCode: |
| def __init__(self, code, id=None): | ||
| self.code = code | ||
| if id: | ||
| self.message = 'Invalid ID passed! {}'.format(id) | ||
| self.message = "Invalid ID passed! {}".format(id) | ||
|
|
||
| super().__init__(self.code, self.message) |
Copilot
AI
Jan 18, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The BrawlerNotFound exception doesn't initialize self.message when id is None or falsy. This will cause an AttributeError when the exception is raised without an id parameter, since str tries to access self.message.
| ) | ||
| name="brawlpy", | ||
| packages=["brawlpy"], | ||
| version="1.2.5", |
Copilot
AI
Jan 18, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The version number in setup.py is still "1.2.5" but the PR title mentions updating to "1.3.0" and version in init.py has been updated to "1.3.0". These should be consistent.
| self.code = code | ||
| self.url = url | ||
| self.message = f'An unexpected error has occured.\n{text}' | ||
| self.message = f"An unexpected error has occured.\n{text}" |
Copilot
AI
Jan 18, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spelling error: "occured" should be "occurred" (double 'r').
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This pull request introduces several improvements and updates to the
brawlpylibrary, focusing on improving usability, code readability, and functionality. The most significant changes include the addition of an asynchronous context manager for theClientclass, refactoring of code for consistency and clarity, and updates to theREADME.mddocumentation.Enhancements to
Clientfunctionality:__aenter__and__aexit__) to theClientclass, allowing the use ofasync withfor managing the client session lifecycle. ([brawlpy/main.pyL4-R66](https://github.com/PyStarr/BrawlPy/pull/4/files#diff-7cc0a1ecc2a1c7abbc754e5233bba68d768b7c92bacaa599c40be70f85c52b13L4-R66))requestmethod in theClientclass to handle session initialization errors and improve error handling. ([brawlpy/main.pyL4-R66](https://github.com/PyStarr/BrawlPy/pull/4/files#diff-7cc0a1ecc2a1c7abbc754e5233bba68d768b7c92bacaa599c40be70f85c52b13L4-R66))Clientmethods (get_player,get_club,brawlers,events, etc.) to use consistent string formatting and improved object creation for better readability. ([[1]](https://github.com/PyStarr/BrawlPy/pull/4/files#diff-7cc0a1ecc2a1c7abbc754e5233bba68d768b7c92bacaa599c40be70f85c52b13L40-R142),[[2]](https://github.com/PyStarr/BrawlPy/pull/4/files#diff-7cc0a1ecc2a1c7abbc754e5233bba68d768b7c92bacaa599c40be70f85c52b13L113-R206),[[3]](https://github.com/PyStarr/BrawlPy/pull/4/files#diff-7cc0a1ecc2a1c7abbc754e5233bba68d768b7c92bacaa599c40be70f85c52b13L143-R246),[[4]](https://github.com/PyStarr/BrawlPy/pull/4/files#diff-7cc0a1ecc2a1c7abbc754e5233bba68d768b7c92bacaa599c40be70f85c52b13L179-R284),[[5]](https://github.com/PyStarr/BrawlPy/pull/4/files#diff-7cc0a1ecc2a1c7abbc754e5233bba68d768b7c92bacaa599c40be70f85c52b13L211-R334),[[6]](https://github.com/PyStarr/BrawlPy/pull/4/files#diff-7cc0a1ecc2a1c7abbc754e5233bba68d768b7c92bacaa599c40be70f85c52b13L249-R377))Documentation updates:
README.mdto reflect the addition of the context manager for theClientclass and corrected the installation command to point to the new repository URL. ([[1]](https://github.com/PyStarr/BrawlPy/pull/4/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5L12-R16),[[2]](https://github.com/PyStarr/BrawlPy/pull/4/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5L25-R25),[[3]](https://github.com/PyStarr/BrawlPy/pull/4/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5R37),[[4]](https://github.com/PyStarr/BrawlPy/pull/4/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5R55))Codebase cleanup and consistency:
[[1]](https://github.com/PyStarr/BrawlPy/pull/4/files#diff-e5556f1147ae675e7061baebb2e7cddb9cc1d9006f03a765720373d6c3a2ab39L1-R3),[[2]](https://github.com/PyStarr/BrawlPy/pull/4/files#diff-2bf9fd80d007a3cb5d23139ad5bc9470436f2600e5389ca46ad74ac8cb11a833R20-R85),[[3]](https://github.com/PyStarr/BrawlPy/pull/4/files#diff-7cc0a1ecc2a1c7abbc754e5233bba68d768b7c92bacaa599c40be70f85c52b13L40-R142))brawlpy/__init__.pyandbrawlpy/main.pyto explicitly list imported classes and objects, improving clarity and reducing wildcard imports. ([[1]](https://github.com/PyStarr/BrawlPy/pull/4/files#diff-d41c6849699852c678513a728c4873b8775605d8bdc527a3023671d786dad7fcL11-R47),[[2]](https://github.com/PyStarr/BrawlPy/pull/4/files#diff-7cc0a1ecc2a1c7abbc754e5233bba68d768b7c92bacaa599c40be70f85c52b13L4-R66))brawlpy/errors.pyand other files. ([[1]](https://github.com/PyStarr/BrawlPy/pull/4/files#diff-2bf9fd80d007a3cb5d23139ad5bc9470436f2600e5389ca46ad74ac8cb11a833R10),[[2]](https://github.com/PyStarr/BrawlPy/pull/4/files#diff-7cc0a1ecc2a1c7abbc754e5233bba68d768b7c92bacaa599c40be70f85c52b13L4-R66))Bug fixes and minor improvements:
brawlpy/icons.pyto adhere to JSON formatting standards. ([brawlpy/icons.pyL55-R55](https://github.com/PyStarr/BrawlPy/pull/4/files#diff-fa51c3a021755e8ac61ec64529779176eb6aeb90b07ba5e2457167d09d129362L55-R55))[[1]](https://github.com/PyStarr/BrawlPy/pull/4/files#diff-2bf9fd80d007a3cb5d23139ad5bc9470436f2600e5389ca46ad74ac8cb11a833R20-R85),[[2]](https://github.com/PyStarr/BrawlPy/pull/4/files#diff-7cc0a1ecc2a1c7abbc754e5233bba68d768b7c92bacaa599c40be70f85c52b13L40-R142))