fix: support datetime.now() in standard execution (#330)#333
Draft
nurikk wants to merge 1 commit intopydantic:mainfrom
Draft
fix: support datetime.now() in standard execution (#330)#333nurikk wants to merge 1 commit intopydantic:mainfrom
nurikk wants to merge 1 commit intopydantic:mainfrom
Conversation
Route `OsFunction::DateTimeNow` / `OsFunction::DateToday` through a new host-clock fallback in `run_to_completion`, so the non-iterative paths (`MontyRun::run`, REPL `feed_run`) can satisfy `datetime.now()` and `date.today()` without requiring the caller to wire up suspend/resume plumbing. The iterative `start`/`resume` path still yields `RunProgress::OsCall`, preserving deterministic host overrides for snapshotted workflows.
Merging this PR will not alter performance
Comparing Footnotes
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Member
|
I would just fix this for the CLI as you originally suggested in #330. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
datetime.now()not supported in standard execution #330:datetime.now()previously raisedNotImplementedError: OS function 'datetime.now' not implemented with standard execution.OsCall::DateTimeNowandOsCall::DateTodayby reading the host wall-clock directly, instead of falling through to the unimplemented path.start/resumecallers are untouched — hosts can still inject a deterministic clock viaRunProgress::OsCall.Approach
host_date_today()/host_datetime_now(tz)helpers incrates/monty/src/os.rsusechronoto produceMontyObject::Date/MontyObject::DateTime. Aware tz mirrors the existing test harness pattern (UTC shifted by fixed offset) and preserves the caller'stzsodatetime.tzinfo is tzholds.Executor::run_to_completionincrates/monty/src/run.rsintercepts only the clock variants ofFrameExit::OsCall; filesystem/env OS calls still surface asNotImplementedError, preserving the sandbox model.Test plan
crates/monty/test_cases/datetime__now_standard.pycovers naive, UTC, fixed-offset,tz=kwarg,tz=None, anddate.today()— passes on Monty and CPython.cargo test -p monty --features ref-count-panicpasses (incl. iterativeos_tests.rs).make pytest: 891 passed.cargo clippy ... -D warnings,cargo fmt --check,make lint-pyall clean.