Skip to content
Merged
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
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ run.patch = [ "subprocess" ]
run.relative_files = true
run.source = [ "ci/", "src/", "tests/" ]
report.exclude_also = [
"case _ as unreachable:\n\\s*assert_never\\(",
"class .*\\bProtocol\\):",
"if TYPE_CHECKING:",
]
Expand Down
15 changes: 9 additions & 6 deletions src/mock_vws/_flask_server/target_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import json
from enum import StrEnum, auto
from http import HTTPMethod, HTTPStatus
from typing import assert_never
from zoneinfo import ZoneInfo

from beartype import beartype
Expand Down Expand Up @@ -37,17 +38,19 @@ class _TargetRaterChoice(StrEnum):
PERFECT = auto()
RANDOM = auto()

def to_target_rater(self) -> TargetTrackingRater:
def to_target_rater(
self: _TargetRaterChoice,
) -> TargetTrackingRater:
"""Get the target rater."""
match self:
case self.BRISQUE:
case _TargetRaterChoice.BRISQUE:
return BrisqueTargetTrackingRater()
case self.PERFECT:
case _TargetRaterChoice.PERFECT:
return HardcodedTargetTrackingRater(rating=5)
case self.RANDOM:
case _TargetRaterChoice.RANDOM:
return RandomTargetTrackingRater()
case _: # pragma: no cover
raise ValueError
case _ as unreachable:
assert_never(unreachable)


@beartype
Expand Down
11 changes: 6 additions & 5 deletions src/mock_vws/_flask_server/vwq.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import time
from enum import StrEnum, auto
from http import HTTPMethod, HTTPStatus
from typing import assert_never

import requests
from beartype import beartype
Expand Down Expand Up @@ -39,15 +40,15 @@ class _ImageMatcherChoice(StrEnum):
EXACT = auto()
STRUCTURAL_SIMILARITY = auto()

def to_image_matcher(self) -> ImageMatcher:
def to_image_matcher(self: _ImageMatcherChoice) -> ImageMatcher:
"""Get the image matcher."""
match self:
case self.EXACT:
case _ImageMatcherChoice.EXACT:
return ExactMatcher()
case self.STRUCTURAL_SIMILARITY:
case _ImageMatcherChoice.STRUCTURAL_SIMILARITY:
return StructuralSimilarityMatcher()
case _: # pragma: no cover
raise ValueError
case _ as unreachable:
assert_never(unreachable)


@beartype
Expand Down
11 changes: 6 additions & 5 deletions src/mock_vws/_flask_server/vws.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import uuid
from enum import StrEnum, auto
from http import HTTPMethod, HTTPStatus
from typing import assert_never

import requests
from beartype import beartype
Expand Down Expand Up @@ -62,15 +63,15 @@ class _ImageMatcherChoice(StrEnum):
EXACT = auto()
STRUCTURAL_SIMILARITY = auto()

def to_image_matcher(self) -> ImageMatcher:
def to_image_matcher(self: _ImageMatcherChoice) -> ImageMatcher:
"""Get the image matcher."""
match self:
case self.EXACT:
case _ImageMatcherChoice.EXACT:
return ExactMatcher()
case self.STRUCTURAL_SIMILARITY:
case _ImageMatcherChoice.STRUCTURAL_SIMILARITY:
return StructuralSimilarityMatcher()
case _: # pragma: no cover
raise ValueError
case _ as unreachable:
assert_never(unreachable)


@beartype
Expand Down
Loading