-
Notifications
You must be signed in to change notification settings - Fork 54
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
Player trainer profile link & relatives #81
Conversation
# Conflicts: # app/services/players/profile.py # tests/players/test_players_profile.py
WalkthroughThe pull request introduces enhancements to the Changes
Possibly related PRs
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (2)
app/services/players/profile.py (1)
31-53
: Add type hints and fix trailing comma.The implementation looks good, but could benefit from type hints for better code maintainability and IDE support.
- def __parse_player_relatives(self) -> list: + def __parse_player_relatives(self) -> list[dict[str, str]]: """ Parse the list of related players or trainers from the 'Further information' section on the player page Returns: - list: A list of dictionaries, each containing ID, profile URL, name, and profile type + list[dict[str, str]]: A list of dictionaries, each containing ID, profile URL, name, and profile type """ relatives = self.page.xpath(Players.Profile.RELATIVES) result = [] for relative in relatives: url = trim(relative.xpath(Players.Profile.RELATIVE_URL)) name = trim(relative.xpath(Players.Profile.RELATIVE_NAME)) result.append( { "id": extract_from_url(url), "url": url, "name": name, - "profileType": "player" if "spieler" in url else "trainer" + "profileType": "player" if "spieler" in url else "trainer", } )🧰 Tools
🪛 Ruff (0.8.0)
49-49: Trailing comma missing
Add trailing comma
(COM812)
tests/players/test_players_profile.py (1)
54-61
: Add trailing comma in schema definition.For consistency with Python style guidelines, add trailing commas in the schema definition.
"relatives": [ { "id": And(str, len_greater_than_0), "url": And(str, len_greater_than_0), "name": And(str, len_greater_than_0), - "profileType": And(str, len_greater_than_0) + "profileType": And(str, len_greater_than_0), } ],🧰 Tools
🪛 Ruff (0.8.0)
60-60: Trailing comma missing
Add trailing comma
(COM812)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (3)
app/services/players/profile.py
(3 hunks)app/utils/xpath.py
(1 hunks)tests/players/test_players_profile.py
(2 hunks)
🧰 Additional context used
🪛 Ruff (0.8.0)
app/services/players/profile.py
49-49: Trailing comma missing
Add trailing comma
(COM812)
tests/players/test_players_profile.py
60-60: Trailing comma missing
Add trailing comma
(COM812)
210-210: Trailing comma missing
Add trailing comma
(COM812)
🔇 Additional comments (4)
app/services/players/profile.py (1)
111-116
: LGTM! Trainer profile and relatives integration looks good.
The implementation maintains consistency with existing patterns and properly integrates the new fields.
tests/players/test_players_profile.py (1)
199-211
: LGTM! Comprehensive test coverage for new fields.
The schema validation for trainer profile and relatives is thorough and consistent with existing patterns.
🧰 Tools
🪛 Ruff (0.8.0)
210-210: Trailing comma missing
Add trailing comma
(COM812)
app/utils/xpath.py (2)
50-57
: LGTM! Well-structured XPath expressions for new fields.
The XPath expressions for trainer profile and relatives are well-organized and follow the established patterns.
49-49
: Verify the social media toolbar class change.
The social media XPath has been updated to use the new class name. Let's verify this change is consistent across different player profiles.
@McAroon thank you for your contribution, I really appreciate it! |
@felipeall and thank you for the API! |
A couple of additions to the player profile.
Also fixed the social media xpath, since apparently the element's class has been changed.
Example output:
Summary by CodeRabbit
Release Notes
New Features
Bug Fixes
Tests