Skip to content

Commit d64cb82

Browse files
MarTrepodiclaude
andauthored
Fix/pr 98 CI blockers (#99)
## Description Add autolabeler permissions for pull requests and update integration tests to remove hard coded Comlink game data version. These changes are needed to prevent blocking of PRs. ## Type of Change - [X] 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 - [X] Tests --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 28a2a9c commit d64cb82

4 files changed

Lines changed: 37 additions & 7 deletions

File tree

.github/workflows/labeler.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Auto Label PR
22

33
on:
4-
pull_request:
4+
pull_request_target:
55
types: [opened, synchronize]
66

77
permissions:

tests/integration/test_async_client.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import pytest
44

55
from swgoh_comlink import SwgohComlinkAsync
6-
from swgoh_comlink.helpers import DataItems
76

87
from .conftest import COMLINK_URL, TEST_ALLYCODE
98

@@ -71,8 +70,8 @@ async def test_get_guilds_by_name(async_comlink):
7170

7271

7372
async def test_get_game_data_filtered(async_comlink):
74-
"""POST /data with DataItems filter returns game data subset."""
75-
result = await async_comlink.get_game_data(items=DataItems.SEGMENT1)
73+
"""POST /data with request_segment=1 returns a non-empty game data subset."""
74+
result = await async_comlink.get_game_data(request_segment=1)
7675
assert isinstance(result, dict)
7776
assert len(result) > 0
7877

tests/integration/test_sync_client.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import pytest
44

55
from swgoh_comlink import SwgohComlink
6-
from swgoh_comlink.helpers import DataItems
76

87
from .conftest import COMLINK_URL, TEST_ALLYCODE
98

@@ -71,8 +70,8 @@ def test_get_guilds_by_name(comlink):
7170

7271

7372
def test_get_game_data_filtered(comlink):
74-
"""POST /data with DataItems filter returns game data subset."""
75-
result = comlink.get_game_data(items=DataItems.SEGMENT1)
73+
"""POST /data with request_segment=1 returns a non-empty game data subset."""
74+
result = comlink.get_game_data(request_segment=1)
7675
assert isinstance(result, dict)
7776
assert len(result) > 0
7877

tests/unit/test_base.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,21 @@
55
import hashlib
66
import logging
77
from json import dumps
8+
from typing import TYPE_CHECKING
89

910
import pytest
1011

1112
from swgoh_comlink import SwgohComlink
1213
from swgoh_comlink._base import _SENSITIVE_KEYS, SwgohComlinkBase, param_alias, sanitize_url
1314
from swgoh_comlink.exceptions import SwgohComlinkValueError
1415

16+
if TYPE_CHECKING:
17+
# `typing.assert_type` is 3.11+; `typing_extensions` works on every
18+
# supported Python version and is already in the dev dependency closure.
19+
from typing_extensions import assert_type
20+
21+
from swgoh_comlink import SwgohComlinkAsync
22+
1523
# ── sanitize_url ─────────────────────────────────────────────────────────
1624

1725

@@ -79,6 +87,30 @@ def test_cannot_instantiate_base_directly(self):
7987
SwgohComlinkBase()
8088

8189

90+
# ── Constructor type inference (PR #98 regression guard) ─────────────────
91+
#
92+
# `SwgohComlinkBase.__new__` must return `Self` so that subclass constructor
93+
# calls infer as the concrete subclass, not the base. Without this, type
94+
# checkers reject subclass-only attribute access such as
95+
# `SwgohComlink(...).get_player(...)`.
96+
#
97+
# The function below is intentionally never invoked at runtime — it lives
98+
# under `if TYPE_CHECKING:` so the static type checker (mypy / ty) validates
99+
# the `assert_type` calls without spinning up real httpx clients.
100+
101+
if TYPE_CHECKING:
102+
103+
def _typecheck_constructor_returns_concrete_subclass() -> None:
104+
sync_client = SwgohComlink()
105+
assert_type(sync_client, SwgohComlink)
106+
# Subclass-only attribute access — must resolve without error.
107+
_ = sync_client.get_player
108+
109+
async_client = SwgohComlinkAsync()
110+
assert_type(async_client, SwgohComlinkAsync)
111+
_ = async_client.get_player
112+
113+
82114
# ── Constructor ──────────────────────────────────────────────────────────
83115

84116

0 commit comments

Comments
 (0)