Skip to content

Commit

Permalink
reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
lubaskinc0de committed Jun 8, 2024
1 parent 89a45a6 commit 5f421a1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/adaptix/_internal/morphing/concrete_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def datetime_format_dumper(data: datetime):
@dataclass
@for_predicate(datetime)
class DatetimeTimestampProvider(LoaderProvider, DumperProvider):
tz: typing.Optional[timezone] = timezone.utc
tz: typing.Optional[timezone] = None

def _provide_loader(self, mediator: Mediator, request: LoaderRequest) -> Loader:
tz = self.tz
Expand All @@ -93,7 +93,7 @@ def datetime_timestamp_loader(data):
raise TypeLoadError(float, data)
except OverflowError:
raise ValueLoadError(
"Timestamp is out of the range of values supported",
"Timestamp is out of the range of supported values",
data,
)

Expand All @@ -119,7 +119,7 @@ def date_timestamp_loader(data):
raise TypeLoadError(float, data)
except OverflowError:
raise ValueLoadError(
"Timestamp is out of the range of values supported",
"Timestamp is out of the range of supported values",
data,
)

Expand Down
3 changes: 1 addition & 2 deletions src/adaptix/_internal/morphing/facade/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,7 @@ def datetime_timestamp_provider(pred: Pred, tz: Optional[timezone] = None) -> Pr
:param tz: tz parameter which will be passed to the datetime.fromtimestamp method.
"""

provider = DatetimeTimestampProvider(tz) if tz else DatetimeTimestampProvider()
return bound(pred, provider)
return bound(pred, DatetimeTimestampProvider(tz))


def datetime_format_provider(pred: Pred, fmt: str) -> Provider:
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/morphing/test_concrete_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def test_datetime_timestamp_provider(strict_coercion, debug_trail, tz):
overflow_ts = float("inf")

raises_exc(
ValueLoadError("Timestamp is out of the range of values supported", overflow_ts),
ValueLoadError("Timestamp is out of the range of supported values", overflow_ts),
lambda: loader(overflow_ts),
)

Expand Down Expand Up @@ -192,7 +192,7 @@ def test_date_timestamp_provider(strict_coercion, debug_trail):
overflow_ts = float("inf")

raises_exc(
ValueLoadError("Timestamp is out of the range of values supported", overflow_ts),
ValueLoadError("Timestamp is out of the range of supported values", overflow_ts),
lambda: loader(overflow_ts),
)

Expand Down

0 comments on commit 5f421a1

Please sign in to comment.