Skip to content

Python versions#279

Merged
doluk merged 10 commits into
masterfrom
python-versions
Nov 28, 2025
Merged

Python versions#279
doluk merged 10 commits into
masterfrom
python-versions

Conversation

@doluk

@doluk doluk commented Nov 18, 2025

Copy link
Copy Markdown
Collaborator

This pull request introduces several improvements and updates across the codebase, focusing on enhanced metadata handling for game entities, improved time calculations, expanded test coverage, and updates to CI/CD workflows and dependencies. The most significant changes include adding support for internal_name fields, improving the TimeDelta model, updating Python version requirements, and expanding test matrix coverage.

Metadata and Model Improvements:

  • Added support for internal_name (and fallback to originalName) to DataContainer and related classes (coc/abc.py, coc/hero.py, coc/spell.py, coc/troop.py). This improves handling of Supercell internal identifiers across troops, spells, heroes, and equipment. [1] [2] [3] [4] [5] [6] [7] [8]
  • Improved TimeDelta model to support days, hours, minutes, and seconds, with accurate total second calculations and string representations. [1] [2]
  • Enhanced upgrade time parsing to support days, hours, minutes, and seconds for unit upgrades.

Testing and Mock Data:

  • Updated tests/mockdata/players/player/FOUND.json with new fields (leagueTier), corrected and expanded achievement info, and adjusted values to reflect recent game/API changes. [1] [2] [3] [4] [5] [6] [7] [8] [9]
  • Added a Run unit tests step to the CI workflow and improved which example scripts are run.

CI/CD and Dependency Updates:

  • Added a new CodeQL analysis workflow for security scanning.
  • Updated test matrix to include Python 3.10–3.14 and upgraded CI actions for checkout and Python setup.
  • Increased minimum Python version requirement to 3.10 in pyproject.toml.
  • Added and organized development dependencies for pytest and related tools in pyproject.toml.

Bug Fixes and Miscellaneous:

  • Fixed a bug in coc/raid.py where star calculation could fail if the attacks list was empty.
  • Improved cache handling in coc/entry_logs.py to avoid errors when client is None.

…a` handling

- Introduced `internal_name` across spells, troops, heroes, and equipment for better alignment with underlying data source.
- Updated `TimeDelta` class to use a unified `total_seconds` calculation, improving accuracy and consistency.
- Fixed star count calculation bug in Raid API response handling.
- Improved caching logic to handle cases where the client is `None`.
@github-advanced-security

Copy link
Copy Markdown

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

Copilot AI left a comment

Copy link
Copy Markdown

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 introduces comprehensive improvements to the codebase including enhanced metadata handling with internal_name support, improved time calculations via refactored TimeDelta model, expanded Python version support (3.10-3.14), enhanced test coverage, and updated CI/CD workflows with CodeQL security scanning.

Key changes:

  • Added internal_name field support across game entities (troops, spells, heroes, equipment) for better Supercell internal identifier handling
  • Refactored TimeDelta to properly handle days/hours/minutes/seconds with accurate total seconds calculation
  • Updated minimum Python version requirement from 3.9 to 3.10 and expanded CI test matrix to include Python 3.10-3.14
  • Fixed critical bug in raid star calculation when attack list is empty
  • Enhanced mock data and added utility script for regenerating test data

Reviewed Changes

Copilot reviewed 18 out of 23 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/test_clash_meta.py Added comprehensive troop metadata validation tests including internal_name verification
tests/test_capitalraidseasons.py Updated test method signatures and added missing RaidLog initialization parameters
tests/mockdata/regenerate_mockdata.py New utility script for regenerating mock test data from live API
coc/abc.py Added internal_name support to DataContainer and enhanced upgrade time parsing
coc/miscmodels.py Refactored TimeDelta for accurate time calculations with improved string representations
coc/raid.py Fixed potential crash when calculating stars with empty attacks list
coc/entry_logs.py Enhanced None client handling to prevent attribute errors
coc/http.py Added safer dictionary access for API key retrieval
pyproject.toml Updated Python version requirement to 3.10+ and added dev dependencies
.github/workflows/tests.yml Expanded test matrix to Python 3.10-3.14 and added unit test execution
.github/workflows/codeql-analysis.yml Added CodeQL security scanning workflow
Comments suppressed due to low confidence (1)

coc/hero.py:20

  • The class 'Hero' does not override 'eq', but adds the new attribute max_level.
    The class 'Hero' does not override 'eq', but adds the new attribute internal_name.
    The class 'Hero' does not override 'eq', but adds the new attribute _townhall.
    The class 'Hero' does not override 'eq', but adds the new attribute __name.
    The class 'Hero' does not override 'eq', but adds the new attribute __level.
    The class 'Hero' does not override 'eq', but adds the new attribute __village.
    The class 'Hero' does not override 'eq', but adds the new attribute __is_active.
    The class 'Hero' does not override 'eq', but adds the new attribute equipment.
class Hero(DataContainer):

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

* Changes for TH18

* Update Version to 3.10
Fix documentation that is flagging

* fix comments

* Add Missing troops,spells,equipment that seem to have been missed since march

@lukasthaler lukasthaler left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Comment thread coc/miscmodels.py
Comment on lines +179 to +182
(days or 0) * 86400 +
(hours or 0) * 3600 +
(minutes or 0) * 60 +
(seconds or 0)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The or clauses are not really relevant with how the defaults are set up. Not strictly against keeping them in place, either

@doluk doluk merged commit 2909bba into master Nov 28, 2025
2 of 7 checks passed
@doluk doluk deleted the python-versions branch November 28, 2025 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants