Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecation for YAML datetime parsing #82519

Open
wants to merge 2 commits into
base: devel
Choose a base branch
from

Conversation

jborean93
Copy link
Contributor

@jborean93 jborean93 commented Jan 11, 2024

SUMMARY

Add deprecation for having YAML parse plain YAML scalar values as a datetime object. This is to avoid ambiguity in how the final parsed value is formatted as a string when used.

It does not seem like PyYAML exposes a way to determine if the Node value was explicitly tagged or not at the point where the deprecation warning is emitted. This means that we cannot preserve the existing behaviour if explicitly tagged rather than what the PR does which is deprecate all instances where the datetime logic is used.

Fixes: #80948

ISSUE TYPE
  • Feature Pull Request
ADDITIONAL INFORMATION

The YAML 1.2 spec also removes the automatic datetime parsing of string so this is a nice way to eventually be compliant with that version.

Add deprecation for having YAML parse plain YAML scalar values as a
datetime object. This is to avoid ambiguity in how the final parsed
value is formatted as a string when used.
@ansibot ansibot added feature This issue/PR relates to a feature request. needs_triage Needs a first human triage before being processed. has_issue labels Jan 11, 2024
@webknjaz
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jborean93 jborean93 removed the needs_triage Needs a first human triage before being processed. label Jan 11, 2024
@nitzmahone
Copy link
Member

nitzmahone commented Jan 11, 2024

Thanks for playing with this!

We need to have a broader discussion about the ideal YAML tag set we'd like to support, including whether we'll warn (and eventually disable) any support for undesired tags/types or just implicit tag resolution (probably also in the context of YAML 1.2). Once we've got our overall direction, we can set deprecation warnings accordingly (including warn-only-on-touch behaviors with data tagging if we want). Pending the outcome of that discussion, the parser layer knows if a tag was implicit/explicit- that info is currently discarded during the compose phase, but IIRC the API calls needed to smuggle it out on the post-resolved node objects that run through the constructors are all public and supported, so if we need to know the distinction in the constructor, we can.

@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This issue/PR relates to a feature request. has_issue stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Native YAML DateTime literals are coming across as DateTime objects
4 participants