Repository navigation
Accept whole-number floats returned as ints by the Python mutator #7842
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| * Fix `bundle` commands failing with "unexpected change at variables.X.default" when a bundle with Python code has a variable default such as `1.0`, `1e3` or `0012345678901234`. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -135,7 +135,11 @@ func createOverrideVisitor(leftRoot, rightRoot dyn.Value) (applyPythonOutputResu | |
| return right, nil | ||
| } | ||
| }, | ||
| VisitUpdate: func(valuePath dyn.Path, _, right dyn.Value) (dyn.Value, error) { | ||
| VisitUpdate: func(valuePath dyn.Path, left, right dyn.Value) (dyn.Value, error) { | ||
| if isWholeFloatAsInt(left, right) { | ||
| return left, nil | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [AI Generated] nit: |
||
| } | ||
|
|
||
| if !valuePath.HasPrefix(resourcesPath) { | ||
| return dyn.InvalidValue, fmt.Errorf("unexpected change at %q (update)", valuePath.String()) | ||
| } | ||
|
|
@@ -211,3 +215,11 @@ func isOmitemptyDelete(left dyn.Value) bool { | |
| return false | ||
| } | ||
| } | ||
|
|
||
| // isWholeFloatAsInt reports whether right is the int Python returns for the float left. | ||
| // JSON doesn't tell 1.0 from 1, so a float such as a variable default of 1.0 comes | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [AI Generated] nit: It's |
||
| // back from Python as an int. | ||
| func isWholeFloatAsInt(left, right dyn.Value) bool { | ||
| return left.Kind() == dyn.KindFloat && right.Kind() == dyn.KindInt && | ||
| left.MustFloat() == float64(right.MustInt()) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nice to have]
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [AI Generated] Above 2^53 Python returns the float's shortest decimal, not its exact value: |
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[blocking]
.nextchanges/README.mdrequires a trailing PR link on every entry and CI enforces it. Append([#7842](https://github.com/databricks/cli/pull/7842))after the period.