Repository navigation
Conversation
Passing a generated protocol class as kind makes client.filters() and client.get() return that class, even with arbitrary filter keyword arguments. Only a one-off reveal_type check during review of #1218 showed this. The new module asserts those types with assert_type(), for the async and sync clients. ty checks it through the existing `ty check .` lint step; a unit test runs mypy on it, because CI runs mypy only over infrahub_sdk/. Widening the filters() protocol overload to list[Any] makes both checks fail. Refs: INBOX-199 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add filters(kind=P, **filters) with a dict[str, Any], a positional string kind for get(), and the guide's role__value plus include call. Run mypy with --follow-imports=silent so the test reports only errors in its own file: the mypy CI step already checks infrahub_sdk/, and the dependency-lower-bounds job would otherwise check it against the lowest dependency versions. Refs: INBOX-199 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add the explicit raise_when_missing=True overload for both clients, reuse PYPROJECT_FILE from tests/constants.py, and state in the module docstring which get() calls resolve to a type callers would not want and are therefore not pinned: an unpacked filters dictionary (Any) and a bool variable for raise_when_missing (the protocol type without None). Refs: INBOX-199 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Deploying infrahub-sdk-python with
|
| Latest commit: |
6195b5e
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://1b2731fe.infrahub-sdk-python.pages.dev |
| Branch Preview URL: | https://pha-inbox-199.infrahub-sdk-python.pages.dev |
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## stable #1576 +/- ##
==========================================
- Coverage 88.30% 87.89% -0.41%
==========================================
Files 157 157
Lines 16310 15660 -650
Branches 2410 2114 -296
==========================================
- Hits 14402 13765 -637
- Misses 1332 1335 +3
+ Partials 576 560 -16
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
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.
tests/unit/sdk/test_client_overload_types.pypins the types thatget()andfilters()return when a protocol class is passed askind, forInfrahubClientandInfrahubClientSync, including calls with several filter keyword arguments, an unpackeddict[str, Any]of filters, andraise_when_missing. ty checks the module through the existingty check .lint step. A unit test runs mypy on it (--follow-imports=silent), because CI runs mypy only overinfrahub_sdk/. No production code, dependency or CI workflow changes.Widening the protocol overloads of
filters()tolist[Any], or ofget()toAny, makes 6 assertions fail under each checker. Twoget()calls are left unpinned and listed in the module docstring, because both checkers already resolve them to a type callers would not want:get(kind=P, **filters)returnsAny, andget(kind=P, raise_when_missing=flag)with aboolvariable returnsPinstead ofP | None. The test imports mypy directly instead of skipping when it is missing, so the guard cannot switch itself off; CI installs it with--all-groups.Tracked as INBOX-199; the question it answers was raised in review of #1218.
🤖 Generated with Claude Code