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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Other changes

* Replaced use of `sys.stderr.write()` with `print(file=sys.stderr)`, because on some platforms `sys.stderr` can be `None`. (#1131)
* Replaced deprecated `datetime` method calls with `datetime.fromtimestamp(tz=timezone.utc)` and `datetime.now(timezone.utc)`. (#1142)


## [0.7.1] - 2024-02-05
Expand Down
8 changes: 4 additions & 4 deletions shiny/input_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

__all__ = ("input_handlers",)

from datetime import date, datetime
from datetime import date, datetime, timezone
from typing import TYPE_CHECKING, Any, Callable, Dict

if TYPE_CHECKING:
Expand Down Expand Up @@ -113,10 +113,10 @@ def _(
value: int | float | list[int] | list[float], name: ResolvedId, session: Session
) -> datetime | tuple[datetime, datetime]:
if isinstance(value, (int, float)):
return datetime.utcfromtimestamp(value)
return datetime.fromtimestamp(value, timezone.utc)
return (
datetime.utcfromtimestamp(value[0]),
datetime.utcfromtimestamp(value[1]),
datetime.fromtimestamp(value[0], timezone.utc),
datetime.fromtimestamp(value[1], timezone.utc),
)


Expand Down
2 changes: 1 addition & 1 deletion shiny/plotutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def near_points(
if all_rows:
# Add selected_ column if needed
new_df["selected_"] = False
new_df.iloc[
new_df.iloc[ # pyright: ignore[reportArgumentType]
keep_idx,
new_df.columns.get_loc( # pyright: ignore[reportUnknownMemberType]
"selected_"
Expand Down
4 changes: 2 additions & 2 deletions tests/playwright/shiny/inputs/input_task_button/app.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import asyncio
from datetime import datetime
from datetime import datetime, timezone

from shiny import reactive, render
from shiny.express import input, ui
Expand All @@ -10,7 +10,7 @@
@render.text()
def current_time() -> str:
reactive.invalidate_later(0.1)
return str(datetime.now().utcnow())
return str(datetime.now(timezone.utc).isoformat())


with ui.p():
Expand Down