Repository navigation
feat(client): add strip_empty option to get_game_data - #267
Merged
Merged
Conversation
/data returns every collection key, populating only the requested ones: unrequested list collections come back as [] and unrequested single-object collections as null. The new keyword-only strip_empty flag drops those keys so the response holds only the collections that came back with data. Falsy scalars such as 0, False and "" are kept. Defaults to False, so existing callers get the full response unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a keyword-only
strip_emptyoption toget_game_data()on bothSwgohComlinkandSwgohComlinkAsync. It defaults toFalse, so existing callers get the full response unchanged./dataalways returns every collection key and populates only the requested ones. Unrequested list collections come back as[]and unrequested single-object collections (guildBanner,socialStatus, …) asnull. Withstrip_empty=Truethose keys are dropped.get_game_data(..., device_platform="Android", *, strip_empty=False) payload = _build_game_data_payload(...) game_data = _post("data", payload) + if strip_empty + drop keys whose value is None, [] or {} + (falsy scalars such as 0, False and "" are kept) return game_dataThe filter is a staticmethod on
SwgohComlinkBase(_strip_empty_collections), next to_build_game_data_payload, so both clients share it.Related Issues
None.
Type of Change
Checklist
developbranch (only release PRs targetmain)feat:,fix:,refactor:, etc.) — they become the changelogCHANGELOG.mdby hand (it is generated from commit messages)README.md,docs/,examples/) if user-facing behavior changeduv run pytest tests/)uv run ruff check src/ tests/anduv run ruff format --check src/ tests/)uv run ty check src/swgoh_comlink/)Testing
Unit tests (
tests/unit/test_client_requests.py, run against both clients):uv run pytest tests/: 2099 passed, 31 skipped.Against a public Comlink release:
strip_emptystrip_empty=Trueitems=DataItems.UNITSunits, 11,582 entries, identical)items=DataItems.SKILL | DataItems.ABILITY(async)ability,skillrequest_segment=1The first live run kept 6 keys that held no data. They were single-object collections returned as
null, which is whyNonecounts as empty.Docs: the README method table and both
examples/*/get_game_data.pyshow the option. Both examples run cleanly.Merge Danger
Door: two-way. The option is new, opt-in and keyword-only; reverting removes it without touching any other behaviour.
Blast Radius: minimal. The default path only adds one
ifafter the response is decoded. Callers who opt in should index with.get(), because collections they did not request are no longer present as keys.🤖 Generated with Claude Code