Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
✅ PR preview is ready!
|
26407f5 to
ffaed7f
Compare
📈 Python coverage change detectedThe Python unit test coverage has increased by 0.0574%
🎉 Great job on improving test coverage! Coverage by files
|
📈 Frontend coverage change detectedThe frontend unit test (vitest) coverage has increased by 0.1100%
🎉 Great job on improving test coverage! |
ffaed7f to
bdcf326
Compare
80ab119 to
12fd2db
Compare
4432fa3 to
7ea5e4d
Compare
frontend/lib/src/components/widgets/DateTimeInput/DateTimeInput.tsx
Outdated
Show resolved
Hide resolved
7ea5e4d to
4678ed5
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR implements a new st.datetime_input widget that allows users to select both date and time values. The implementation follows Streamlit's established patterns for widget creation, including full backend support, React frontend component, protobuf message definitions, and comprehensive test coverage across Python unit tests, TypeScript unit tests, and Playwright E2E tests.
Key changes:
- New datetime picker widget combining date and time selection with configurable step intervals and format options
- Backend support for various input types (datetime, date, time, ISO strings, "now" keyword)
- AppTest integration for programmatic testing
- Visual snapshot testing across multiple browsers and themes
Reviewed Changes
Copilot reviewed 17 out of 95 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
proto/streamlit/proto/DateTimeInput.proto |
Defines protobuf message structure for datetime widget communication |
proto/streamlit/proto/Element.proto |
Integrates DateTimeInput into Element union |
lib/streamlit/elements/widgets/time_widgets.py |
Core backend implementation with value parsing, validation, and widget registration |
lib/streamlit/__init__.py |
Exports datetime_input to public API |
lib/streamlit/testing/v1/element_tree.py |
AppTest support for DateTimeInput widget |
lib/streamlit/testing/v1/app_test.py |
Exposes datetime_input property in AppTest |
lib/tests/streamlit/typing/datetime_input_types.py |
Type checking tests for public API |
lib/tests/streamlit/elements/datetime_input_test.py |
Python unit tests for backend logic |
lib/tests/streamlit/element_mocks.py |
Test helper registration |
lib/tests/streamlit/delta_generator_test.py |
Duplicate widget ID test coverage |
frontend/lib/src/components/widgets/DateTimeInput/DateTimeInput.tsx |
React component implementation |
frontend/lib/src/components/widgets/DateTimeInput/DateTimeInput.test.tsx |
Frontend unit tests |
frontend/lib/src/components/widgets/DateTimeInput/index.ts |
Component export |
frontend/lib/src/components/core/Block/ElementNodeRenderer.tsx |
Renderer integration |
e2e_playwright/st_datetime_input.py |
Test application demonstrating widget features |
e2e_playwright/st_datetime_input_test.py |
E2E test suite |
e2e_playwright/shared/app_utils.py |
Test utility for locating datetime inputs |
e2e_playwright/__snapshots__/ |
Visual regression test snapshots (multiple PNG files) |
sfc-gh-bnisco
left a comment
There was a problem hiding this comment.
Thanks for this PR! I've left some comments inline, let me know if you want to chat about any of them.
frontend/lib/src/components/widgets/DateTimeInput/DateTimeInput.tsx
Outdated
Show resolved
Hide resolved
frontend/lib/src/components/widgets/DateTimeInput/DateTimeInput.tsx
Outdated
Show resolved
Hide resolved
frontend/lib/src/components/widgets/DateTimeInput/DateTimeInput.tsx
Outdated
Show resolved
Hide resolved
frontend/lib/src/components/widgets/DateTimeInput/DateTimeInput.tsx
Outdated
Show resolved
Hide resolved
frontend/lib/src/components/widgets/DateTimeInput/DateTimeInput.tsx
Outdated
Show resolved
Hide resolved
frontend/lib/src/components/widgets/DateTimeInput/DateTimeInput.test.tsx
Outdated
Show resolved
Hide resolved
frontend/lib/src/components/widgets/DateTimeInput/DateTimeInput.test.tsx
Outdated
Show resolved
Hide resolved
frontend/lib/src/components/widgets/DateTimeInput/DateTimeInput.test.tsx
Outdated
Show resolved
Hide resolved
eb5f736 to
b8c0e10
Compare
Yeah it handles them the same way, basically strips the timezones (also documented) |
Time can apparently have a timezone attached to it (even though it's not very useful). @sfc-gh-aamadhavan can you check what |
| if not isinstance(step, (int, timedelta)): | ||
| raise StreamlitAPIException( | ||
| f"`step` can only be `int` or `timedelta` but {type(step)} is provided." | ||
| ) | ||
| step_seconds = ( | ||
| int(step.total_seconds()) if isinstance(step, timedelta) else step | ||
| ) | ||
| if step_seconds < 60 or step_seconds > timedelta(hours=23).seconds: | ||
| raise StreamlitAPIException( | ||
| f"`step` must be between 60 seconds and 23 hours but is currently set to {step_seconds} seconds." | ||
| ) |
There was a problem hiding this comment.
The step validation logic should include an explicit check for negative values. Currently, a negative step value could pass the validation if it's less than -timedelta(hours=23).seconds, which would create unexpected behavior. Consider adding a simple check like if step_seconds <= 0: before the existing range check to ensure only positive step values are accepted.
| if not isinstance(step, (int, timedelta)): | |
| raise StreamlitAPIException( | |
| f"`step` can only be `int` or `timedelta` but {type(step)} is provided." | |
| ) | |
| step_seconds = ( | |
| int(step.total_seconds()) if isinstance(step, timedelta) else step | |
| ) | |
| if step_seconds < 60 or step_seconds > timedelta(hours=23).seconds: | |
| raise StreamlitAPIException( | |
| f"`step` must be between 60 seconds and 23 hours but is currently set to {step_seconds} seconds." | |
| ) | |
| if not isinstance(step, (int, timedelta)): | |
| raise StreamlitAPIException( | |
| f"`step` can only be `int` or `timedelta` but {type(step)} is provided." | |
| ) | |
| step_seconds = ( | |
| int(step.total_seconds()) if isinstance(step, timedelta) else step | |
| ) | |
| if step_seconds <= 0: | |
| raise StreamlitAPIException( | |
| f"`step` must be a positive value but is currently set to {step_seconds} seconds." | |
| ) | |
| if step_seconds < 60 or step_seconds > timedelta(hours=23).seconds: | |
| raise StreamlitAPIException( | |
| f"`step` must be between 60 seconds and 23 hours but is currently set to {step_seconds} seconds." | |
| ) |
Spotted by Graphite Agent
Is this helpful? React 👍 or 👎 to let us know.
Yeah I checked and replied above before about it, it is just ignored, which is the same behaviour as this. |
|
Ok great then good to go, thx for checking! |
Describe your changes
st.datetime_input, including proto wiring, widget serde, AppTest bindings, and user-facing API.python scripts/update_e2e_snapshots.py --changedmake python-initScreenshot or video (only for visual changes)
DemoVideo.mov
GitHub Issue Link (if applicable)
Closes #6089
Testing Plan
Explanation of why no additional tests are needed
The feature ships with dedicated Python unit tests, typing checks, frontend unit tests, and comprehensive Playwright coverage, so no further manual tests are required.
Unit Tests (JS and/or Python)
PYTHONPATH=lib pytest lib/tests/streamlit/elements/datetime_input_test.pyyarn test lib/src/components/widgets/DateTimeInput/DateTimeInput.test.tsxE2E Tests
make run-e2e-test e2e_playwright/st_datetime_input_test.py(re-run after rebuilding the frontend)Any manual testing needed?
None beyond the automated suite.
Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.