Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
default_stages: [pre-commit]
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.3
rev: v0.14.10
hooks:
- id: ruff-check
args: [--fix]
Expand All @@ -15,8 +15,10 @@ repos:
- id: trailing-whitespace
- id: check-merge-conflict

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.18.2
- repo: local # till there is an official one https://github.com/astral-sh/ty/issues/269
hooks:
- id: mypy
files: openfeature|tests/typechecking
- id: ty
name: ty check
entry: uv run --frozen ty check
pass_filenames: false
language: system
4 changes: 2 additions & 2 deletions openfeature/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ async def _create_provider_evaluation_async(

resolution = await get_details_callable(
flag_key=flag_key,
default_value=default_value,
default_value=default_value, # ty: ignore[invalid-argument-type]
evaluation_context=evaluation_context,
)
if resolution.error_code:
Expand Down Expand Up @@ -949,7 +949,7 @@ def _create_provider_evaluation(

resolution = get_details_callable(
flag_key=flag_key,
default_value=default_value,
default_value=default_value, # ty: ignore[invalid-argument-type]
evaluation_context=evaluation_context,
)
if resolution.error_code:
Expand Down
2 changes: 1 addition & 1 deletion openfeature/immutable_dict/mapping_proxy_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class MappingProxyType(dict):
`from types import MappingProxyType`
"""

def __hash__(self) -> int: # type:ignore[override]
def __hash__(self) -> int:
return id(self)

def _immutable(self, *args: typing.Any, **kws: typing.Any) -> typing.NoReturn:
Expand Down
30 changes: 15 additions & 15 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ dev = [
"coverage[toml]>=6.5",
"pytest",
"pytest-asyncio",
"pre-commit"
"pre-commit",
"ty>=0.0.4,<0.1.0",
]

[tool.uv]
Expand All @@ -44,19 +45,6 @@ module-name = "openfeature"
module-root = ""
namespace = true

[tool.mypy]
files = "openfeature,tests/typechecking"

python_version = "3.9" # should be identical to the minimum supported version
namespace_packages = true
explicit_package_bases = true
local_partial_types = true # will become the new default from version 2
allow_redefinition_new = true # will become the new default from version 2
fixed_format_cache = true # new caching mechanism
pretty = true
strict = true
disallow_any_generics = false

[tool.pytest.ini_options]
asyncio_default_fixture_loop_scope = "function"

Expand Down Expand Up @@ -131,6 +119,18 @@ banned-from = ["typing"]
"typing.MutableMapping".msg = "Use collections.abc.MutableMapping instead"
"typing.MutableSequence".msg = "Use collections.abc.MutableSequence instead"

[tool.ty.environment]
python-version = "3.9"

[tool.ty.src]
include = [
"openfeature",
"tests/typechecking",
]

[tool.ty.rules]
unused-ignore-comment = "error"

[project.scripts]
# workaround while UV doesn't support scripts directly in the pyproject.toml
# see: https://github.com/astral-sh/uv/issues/5903
Expand All @@ -139,4 +139,4 @@ test-cov = "scripts.scripts:test_cov"
cov-report = "scripts.scripts:cov_report"
cov = "scripts.scripts:cov"
e2e = "scripts.scripts:e2e"
precommit = "scripts.scripts:precommit"
precommit = "scripts.scripts:precommit"
6 changes: 3 additions & 3 deletions tests/typechecking/evaluation_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@
# negative
EvaluationContext(
targeting_key="key",
attributes={"null": None}, # type: ignore[dict-item]
attributes={"null": None}, # ty: ignore[invalid-argument-type]
)

EvaluationContext(
targeting_key="key",
attributes={"complex": -4.5j}, # type: ignore[dict-item]
attributes={"complex": -4.5j}, # ty: ignore[invalid-argument-type]
)

EvaluationContext(
targeting_key="key",
attributes={42: 42}, # type: ignore[dict-item]
attributes={42: 42}, # ty: ignore[invalid-argument-type]
)
2 changes: 1 addition & 1 deletion tests/typechecking/hook_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ class ExampleClass:
class_hook_data: HookData = {"example": ExampleClass}

# negative
int_key_hook_data: HookData = {42: 42} # type: ignore[dict-item]
int_key_hook_data: HookData = {42: 42} # ty: ignore[invalid-assignment]
6 changes: 3 additions & 3 deletions tests/typechecking/hook_hints.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
}

# negative
null_hook_hint: HookHints = {"null": None} # type: ignore[dict-item]
null_hook_hint: HookHints = {"null": None} # ty: ignore[invalid-assignment]

complex_hook_hint: HookHints = {"complex": -4.5j} # type: ignore[dict-item]
complex_hook_hint: HookHints = {"complex": -4.5j} # ty: ignore[invalid-assignment]

int_key_hook_hint: HookHints = {42: 42} # type: ignore[dict-item]
int_key_hook_hint: HookHints = {42: 42} # ty: ignore[invalid-assignment]
372 changes: 241 additions & 131 deletions uv.lock

Large diffs are not rendered by default.