Skip to content

Feature/async - v2.0.6 - #76

Merged
MarTrepodi merged 52 commits into
mainfrom
feature/async
Mar 29, 2026
Merged

Feature/async - v2.0.6#76
MarTrepodi merged 52 commits into
mainfrom
feature/async

Conversation

@MarTrepodi

Copy link
Copy Markdown
Collaborator

Description

This PR represents the final collection of updates needed to address all outstanding issues related to the stated updates for the v2.0.0 major update.

Related Issues

Closes #51, #72, #63, #62, #61, #60

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Refactor (code change that neither fixes a bug nor adds a feature)
  • Documentation
  • Tests

Checklist

  • My commits follow the Angular commit convention (feat:, fix:, refactor:, etc.)
  • I have added/updated docstrings with type hints for any new or changed public methods
  • I have added unit tests that cover my changes (mocked, not requiring a live comlink service)
  • All existing tests still pass (python -m pytest tests/ -v)
  • Ruff linter passes (ruff check src/ tests/)

Testing

Full current suite of pytests and manual spot validation using samples from the examples folder

MarTrepodi and others added 28 commits March 3, 2026 09:21
….18.0rc1

Add the StatCalc local stat/GP calculator, fix multiple bugs in
calculator.py (duplicate _rename_stats call, calc_player_stats type
errors, print statements), update all documentation to reflect the
StatCalc feature, and remove unused verify-upstream.sh script.
Version set to 1.18.0rc1 for release candidate publication alongside
the stable PyPI release.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Replace `requests` with `httpx` for sync/async HTTP support
- Extract shared logic into `SwgohComlinkBase` abstract base class
- Add `SwgohComlinkAsync` with identical API using async/await
- Refactor logging to follow Python library best practices (NullHandler only)
- Mask `secret_key` and `access_key` in `__repr__` and debug logging
- Add `_SENSITIVE_KEYS` frozenset and `_mask()` helper for consistent masking
- Sanitize kwargs in `func_debug_logger` to prevent credential leakage
- Add type annotations to Google-style docstrings for mkdocstrings
- Add mkdocs build step to CI workflow with `--strict` mode
- Add `SwgohComlinkAsync` API reference page to docs
- Update README with dedicated Async and StatCalc sections
- Rewrite `docs/logging.md` for NullHandler approach
- Add 110 unit tests (100% coverage on core modules)
- Introduce `docs/migration.md` covering dependency updates, exception handling, logging changes, and client lifecycle.
- Add migration summary to the README with key actions and a link to the full guide.
- Update `mkdocs.yml` to include the migration guide in the navigation.
…ncio-based scripts

- Removed the outdated `threaded_player_fetch.py` script.
- Added multiple new examples utilizing `SwgohComlinkAsync`, including:
  - `async/concurrent_requests.py`
  - `async/streaming_guild_roster.py`
  - `async/get_guild_leaderboard.py` and more for async capabilities.
- Updated `examples/README.md` with descriptions and directory structure for better organization between `Sync` and `Async` examples.
…oading

- Added `GameDataBuilder` and `GameDataBuilderAsync` modules to support dynamic game data generation from a running Comlink service instead of relying on static files.
- Enhanced README, API docs, and examples to demonstrate the use of `GameDataBuilder`.
- Updated examples for both sync and async workflows to showcase dynamic and static approaches to stat calculation.
- Updated `CHANGELOG.md` and bumped `StatCalc` functionality for this addition.
Refactor 1,970-line helpers.py into a focused helpers/ subpackage with
12 domain-specific modules. Consolidate 4 duplicate copies of stat data
into a single canonical source in _stat_data.py, eliminating ~800 lines
of redundancy including the 489-line inline STATS_NAME_MAP in
StatCalc/calculator.py. All existing import paths preserved via
backward-compatible re-export shim.

Add swgoh-migrate CLI tool (python -m swgoh_comlink.migrate) for
scanning user codebases to identify deprecated imports, API changes,
and migration steps needed when upgrading from v1.x.

Rewrite legacy test_get_enums and test_get_unit_stats from
requests/mock.patch to pytest-httpx, fixing 5 test failures.
…ulation

- Added logic to calculate and aggregate dismantle materials across multiple datacrons.
- Updated return type from `list` to `dict` for clearer representation of totals.
- Enhanced docstrings with detailed descriptions and type hints.
…t entries

- Grouped stat data imports in `helpers/__init__.py` for better organization and consistency.
- Removed unnecessary blank lines in `test_get_enums.py` and `test_parity.py`.
- Fixed minor import reordering in `_guild.py` for clarity.
- Corrected type hint formatting in `StatCalcAsync.create` method definition.
…nce CI

- Added fixtures in `conftest.py` for shared HMAC/Async test setup.
- Introduced new integration tests for HMAC and async clients, covering both valid and invalid key scenarios.
- Enhanced CI pipeline to include Python 3.14 and integration tests using separate workflows.
- Added integration tests for `SwgohComlink` and `SwgohComlinkAsync` clients, validating enums, metadata, events, and player-related operations.
…ight sentinel class

- Implemented custom `Sentinel` class to remove dependency on the external `sentinels` package.
- Updated `_sentinels.py` with the new implementation and revised sentinel definitions.
- Removed `sentinels` from `pyproject.toml` and lockfiles.
- Refactored `__all__` exports and updated imports to reflect the changes.
- Introduced comprehensive `Helpers` and `Exceptions` API reference documentation.
- Enriched `docs/index.md` with links to the new `Helpers` and `Exceptions` docs.
- Updated `mkdocs.yml` to include the new files in the navigation structure.
- Expanded helper module with new async methods for GAC and guild operations.
…GAC bracket handling

- Deleted `OPTIONAL` and `NotSet` sentinels from `helpers` and replaced their usage with type-based defaults (e.g., `None`, `int`).
- Updated `get_gac_brackets()` and `async_get_gac_brackets()` to use int-based `limit` parameter with a default value of `0` (no limit).
- Introduced exponential probing with binary search for GAC bracket boundary detection, optimizing performance from O(n) to O(log n).
- Added parallel batch fetching to `async_get_gac_brackets()` for faster operations via `asyncio.gather`.
- Adjusted docs, migration guide, and tests to align with these updates.
…patibility

- Updated payload serialization to use an empty string (`""`) instead of an empty object (`{}`) when no payload is provided, ensuring compatibility with comlink v4 (#51).
- Added unit test to verify updated behavior and prevent regressions.
- Added explicit checks and error handling for Comlink and HMAC readiness.
- Introduced environment variables for better service identification.
- Enhanced error reporting on service startup failures.
…diness checks

- Expanded commit message scopes in `commitlint` to include additional categories (`version`,
`hmac`, `async`, etc.).
- Dropped Python 3.14 from CI matrix in `ci.yml`.
- Enhanced integration workflow:
  - Changed branch filters to reflect new maintenance structure.
  - Added health checks for services with improved startup readiness validation.
  - Updated `/metadata` endpoint to `/readyz` for readiness checks.
- Adjusted branch filters in `commitlint.yml` and `ci.yml` to include `1.0-maintenance`.
- Removed `--strict` flag from the documentation build step in `test.yml`.
- Replaced generic types with more precise annotations (e.g., `dict` → `dict[str, Any]`).
- Added `cast` and `assert` statements for stricter runtime type validation.
- Improved validation for player allycodes and guild IDs with custom exceptions.
- Updated decorators to include detailed type hints for improved clarity.
…mports

- Combined nested `with` statements in HMAC tests for cleaner exception handling.
- Removed unused `pytest` import from `test_gac_helpers.py`.
- Updated GitHub Actions to `checkout@v4`, `setup-python@v6`, and `setup-uv@v7`.
- Restructured `dependency-groups` in `pyproject.toml` for improved organization (`test`,
`typecheck`, `dev`, and `docs` groups).
- Replaced manual pip commands with `uv sync` and `uv run` across workflows for consistency.
- Consolidated and streamlined dependency installation and execution in CI/CD workflows.
…umentation

- Improved steps for environment setup, installation verification, and testing with `uv`.
- Updated project directory tree to reflect new files, restructured modules, and additional tests.
- Aligned type annotation guidelines and testing instructions with stricter `mypy --strict`
enforcement.
- Clarified commit message scopes and contributing checklist with updated
 linter/formatter commands.
- Updated payload construction in `_build_game_data_payload` to handle numeric strings and negative
 values correctly.
- Enhanced StatCalc logic by adding detailed error messages for missing units/ships and ensuring
robust handling of missing progressions or equipment data.
- Improved parsing of stat progression, gear, relic, and mod data by consolidating logic for
handling empty or malformed entries with debug/warning logs.
- Fixed discrepancies between parsed data structures and the in-game reference implementation by
refining parsing rules and iteration over raw data.
- Updated unit tests to cover edge cases related to numeric strings and abnormal payload values.
- Added comprehensive unit tests for `_builder_base.py` transformation logic.
- Verified orchestration via `GameDataBuilderBase._build_game_data`.

Other changes:
- Updated `.gitignore` to exclude `tests/exhaustive/`, `scripts/`, and other support files.
- Bumped version to `2.0.3rc1`.
…ion use cases

- Updated Async and Sync examples with clearer configuration variables for Comlink host/port.
- Enhanced stats calculation examples with additional use cases (basic units, units with
skills/mods, and player roster stats).
- Simplified member ID extraction to handle missing playerIds gracefully.
- Improved documentation in calc_stats examples to align with expanded functionality.
…ure functions

- Expanded test coverage for `helpers` module, including mocking HTTP and testing pure utility
functions.
- Added new files: `tests/unit/test_helpers_mocked.py` and `tests/unit/test_helpers.py` for
structured test cases.
- Improved coverage to 96% as reflected in README.
@MarTrepodi MarTrepodi self-assigned this Mar 8, 2026
@MarTrepodi MarTrepodi added the bug Unintended functionality or behavior label Mar 8, 2026
@MarTrepodi MarTrepodi added the v2.0.0 Tasks related to the planned version 2.0 release label Mar 8, 2026
- Removed unused imports from multiple test files, including `test_builder_base.py`,
`test_helpers_mocked.py`, `test_helpers.py`, and `test_migrate.py`.
- Cleaned up unnecessary blank lines and redundant whitespace for better readability.
- Added `gameData.json` to `tests/resources` for test data reference.
Signed-off-by: MarTrepodi <martrepodi@gmail.com>
…tCalc/calculator.py`, update version to 2.0.6
@MarTrepodi MarTrepodi changed the title Feature/async - v2.0.3rc1 Feature/async - v2.0.6 Mar 29, 2026
@MarTrepodi
MarTrepodi merged commit 8ade128 into main Mar 29, 2026
13 of 15 checks passed
@MarTrepodi
MarTrepodi deleted the feature/async branch April 15, 2026 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Unintended functionality or behavior build Changes to build automation ci Changes related to continuous integration processes code maintenance General code housekeeping items code dependencies Updates to package dependency libraries documentation Improvements or additions to documentation enhancement New feature or request testing v2.0.0 Tasks related to the planned version 2.0 release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update HMAC signing default empty object for comlink v4

1 participant