Skip to content

Commit a853b85

Browse files
authored
chore: remove excluded ruff rules and fix issues (#254)
remove excluded ruff rules and fix issues Signed-off-by: gruebel <anton.gruebel@gmail.com>
1 parent 49aae78 commit a853b85

File tree

10 files changed

+25
-30
lines changed

10 files changed

+25
-30
lines changed

openfeature/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ def evaluate_flag_details(
314314
)
315315
# Catch any type of exception here since the user can provide any exception
316316
# in the error hooks
317-
except Exception as err: # noqa
317+
except Exception as err: # pragma: no cover
318318
error_hooks(flag_type, hook_context, err, reversed_merged_hooks, hook_hints)
319319

320320
error_message = getattr(err, "error_message", str(err))

openfeature/flag_evaluation.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ class Reason(StrEnum):
3131

3232
FlagMetadata = typing.Mapping[str, typing.Any]
3333

34-
T = typing.TypeVar("T", covariant=True)
34+
T_co = typing.TypeVar("T_co", covariant=True)
3535

3636

3737
@dataclass
38-
class FlagEvaluationDetails(typing.Generic[T]):
38+
class FlagEvaluationDetails(typing.Generic[T_co]):
3939
flag_key: str
40-
value: T
40+
value: T_co
4141
variant: typing.Optional[str] = None
4242
flag_metadata: FlagMetadata = field(default_factory=dict)
4343
reason: typing.Optional[Reason] = None
@@ -51,12 +51,12 @@ class FlagEvaluationOptions:
5151
hook_hints: dict = field(default_factory=dict)
5252

5353

54-
U = typing.TypeVar("U", covariant=True)
54+
U_co = typing.TypeVar("U_co", covariant=True)
5555

5656

5757
@dataclass
58-
class FlagResolutionDetails(typing.Generic[U]):
59-
value: U
58+
class FlagResolutionDetails(typing.Generic[U_co]):
59+
value: U_co
6060
error_code: typing.Optional[ErrorCode] = None
6161
error_message: typing.Optional[str] = None
6262
reason: typing.Optional[Reason] = None

openfeature/hook/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ class HookContext:
2626
flag_type: FlagType
2727
default_value: typing.Any
2828
evaluation_context: EvaluationContext
29-
client_metadata: typing.Optional["ClientMetadata"] = None
30-
provider_metadata: typing.Optional["Metadata"] = None
29+
client_metadata: typing.Optional[ClientMetadata] = None
30+
provider_metadata: typing.Optional[Metadata] = None
3131

3232

3333
class Hook:

openfeature/hook/hook_support.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,5 +116,5 @@ def _execute_hook_checked(hook: Hook, hook_method: HookType, **kwargs):
116116
"""
117117
try:
118118
return getattr(hook, hook_method.value)(**kwargs)
119-
except Exception: # noqa
119+
except Exception: # pragma: no cover
120120
logging.error(f"Exception when running {hook_method.value} hooks")

openfeature/provider/in_memory_provider.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,28 @@ class InMemoryMetadata(Metadata):
1717
name: str = "In-Memory Provider"
1818

1919

20-
T = typing.TypeVar("T", covariant=True)
20+
T_co = typing.TypeVar("T_co", covariant=True)
2121

2222

2323
@dataclass(frozen=True)
24-
class InMemoryFlag(typing.Generic[T]):
24+
class InMemoryFlag(typing.Generic[T_co]):
2525
class State(StrEnum):
2626
ENABLED = "ENABLED"
2727
DISABLED = "DISABLED"
2828

2929
default_variant: str
30-
variants: typing.Dict[str, T]
30+
variants: typing.Dict[str, T_co]
3131
flag_metadata: FlagMetadata = field(default_factory=dict)
3232
state: State = State.ENABLED
3333
context_evaluator: typing.Optional[
34-
typing.Callable[["InMemoryFlag", EvaluationContext], FlagResolutionDetails[T]]
34+
typing.Callable[
35+
["InMemoryFlag", EvaluationContext], FlagResolutionDetails[T_co]
36+
]
3537
] = None
3638

3739
def resolve(
3840
self, evaluation_context: typing.Optional[EvaluationContext]
39-
) -> FlagResolutionDetails[T]:
41+
) -> FlagResolutionDetails[T_co]:
4042
if self.context_evaluator:
4143
return self.context_evaluator(
4244
self, evaluation_context or EvaluationContext()

pyproject.toml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,6 @@ select = [
6363
]
6464
ignore = [
6565
"E501", # the formatter will handle any too long line
66-
# all following rules will be removed in the next PR
67-
"PGH004",
68-
"RUF100",
69-
"PLC0105",
70-
"UP037",
71-
"C408",
72-
"I001",
73-
"SIM300",
7466
]
7567
preview = true
7668

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def clear_provider():
1111
in other tests.
1212
"""
1313
yield
14-
_provider = None # noqa: F841
14+
_provider = None
1515

1616

1717
@pytest.fixture()

tests/hook/test_hook_support.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
def test_error_hooks_run_error_method(mock_hook):
1616
# Given
1717
hook_context = HookContext("flag_key", FlagType.BOOLEAN, True, "")
18-
hook_hints = MappingProxyType(dict())
18+
hook_hints = MappingProxyType({})
1919
# When
2020
error_hooks(FlagType.BOOLEAN, hook_context, Exception, [mock_hook], hook_hints)
2121
# Then
@@ -29,7 +29,7 @@ def test_error_hooks_run_error_method(mock_hook):
2929
def test_before_hooks_run_before_method(mock_hook):
3030
# Given
3131
hook_context = HookContext("flag_key", FlagType.BOOLEAN, True, "")
32-
hook_hints = MappingProxyType(dict())
32+
hook_hints = MappingProxyType({})
3333
# When
3434
before_hooks(FlagType.BOOLEAN, hook_context, [mock_hook], hook_hints)
3535
# Then
@@ -61,7 +61,7 @@ def test_after_hooks_run_after_method(mock_hook):
6161
flag_evaluation_details = FlagEvaluationDetails(
6262
hook_context.flag_key, "val", "unknown"
6363
)
64-
hook_hints = MappingProxyType(dict())
64+
hook_hints = MappingProxyType({})
6565
# When
6666
after_hooks(
6767
FlagType.BOOLEAN, hook_context, flag_evaluation_details, [mock_hook], hook_hints
@@ -77,7 +77,7 @@ def test_after_hooks_run_after_method(mock_hook):
7777
def test_finally_after_hooks_run_finally_after_method(mock_hook):
7878
# Given
7979
hook_context = HookContext("flag_key", FlagType.BOOLEAN, True, "")
80-
hook_hints = MappingProxyType(dict())
80+
hook_hints = MappingProxyType({})
8181
# When
8282
after_all_hooks(FlagType.BOOLEAN, hook_context, [mock_hook], hook_hints)
8383
# Then

tests/provider/test_in_memory_provider.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import pytest
21
from numbers import Number
32

3+
import pytest
4+
45
from openfeature.exception import FlagNotFoundError
56
from openfeature.flag_evaluation import FlagResolutionDetails, Reason
67
from openfeature.provider.in_memory_provider import InMemoryFlag, InMemoryProvider

tests/test_flag_evaluation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ def test_evaluation_details_reason_should_be_a_string_when_set():
5353
flag_details.reason = Reason.STATIC
5454

5555
# Then
56-
assert Reason.STATIC == flag_details.reason
56+
assert Reason.STATIC == flag_details.reason # noqa: SIM300

0 commit comments

Comments
 (0)