Skip to content

Commit 15a57bb

Browse files
committed
fix(provider-tck): accept any capability collection, and type-check the tests
TckConfig.capabilities was annotated frozenset[Capability], but the README tells adopters to write `capabilities={Capability.EVENTS, ...}` -- a set literal. Anyone copying the documented example and running mypy got an incompatible-argument error from the suite's own documentation. It is now annotated Collection[Capability], which is what __post_init__ already accepted: a set, a list or a generator all normalise to a frozenset on construction. The reason this was invisible is the second half of the fix. mypy was configured `files = "src"`, so the tests were never checked -- and the tests are the reference adoption, the thing an adopting provider copies. They are now in scope, which is what would have caught the annotation in the first place. Verified: mypy clean over src and tests (17 files), ruff format and check clean, 56 passed / 7 skipped / 2 xfailed. Signed-off-by: Simon Schrottner <simon.schrottner@flagsmith.com>
1 parent 8324d04 commit 15a57bb

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

‎tools/openfeature-provider-tck/pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ packages = ["src/openfeature"]
4747

4848
[tool.mypy]
4949
mypy_path = "src"
50-
files = "src"
50+
files = ["src", "tests"]
5151
python_version = "3.10"
5252
namespace_packages = true
5353
explicit_package_bases = true

‎tools/openfeature-provider-tck/src/openfeature/contrib/tools/provider_tck/config.py‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from collections.abc import Callable, Iterable
5+
from collections.abc import Callable, Collection, Iterable
66
from dataclasses import dataclass, field
77

88
from openfeature.provider import FeatureProvider
@@ -79,9 +79,14 @@ class TckConfig:
7979
skipped with the reason reported.
8080
"""
8181

82-
capabilities: frozenset[Capability] = field(default=ALL_CAPABILITIES)
82+
capabilities: Collection[Capability] = field(default=ALL_CAPABILITIES)
8383
"""Which optional parts of the provider contract this provider supports.
8484
85+
Typed as a ``Collection`` rather than a ``frozenset`` so that the obvious
86+
thing to write -- a set literal, which is what the README shows -- is also
87+
the correctly typed thing to write. It is normalised to a frozenset on
88+
construction, so a list, a set or a generator all behave identically.
89+
8590
Scenarios tagged with an undeclared capability are reported as skipped with
8691
the reason, never as passed. Defaults to everything; narrow it rather than
8792
widening it.

0 commit comments

Comments
 (0)