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 NEXT_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
* Fix handling of Unicode characters in Python support ([#2873](https://github.com/databricks/cli/pull/2873))
* Add support for secret scopes in DABs ([#2744](https://github.com/databricks/cli/pull/2744))
* Make `artifacts.*.type` optional in bundle JSON schema ([#2881](https://github.com/databricks/cli/pull/2881))
* Fix support for `spot_bid_max_price` field in Python support ([#2883](https://github.com/databricks/cli/pull/2883))

### API Changes
2 changes: 2 additions & 0 deletions experimental/python/databricks/bundles/core/_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ def _transform(cls: Type[_T], value: Any) -> _T:
return str(value) # type:ignore
elif cls is int:
return int(value) # type:ignore
elif cls is float:
return float(value) # type:ignore
elif cls is bool:
if isinstance(value, bool):
return value # type:ignore
Expand Down
13 changes: 13 additions & 0 deletions experimental/python/databricks_tests/core/test_transform.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import math
from dataclasses import dataclass
from enum import Enum
from typing import Optional
Expand Down Expand Up @@ -332,3 +333,15 @@ class A:
out = _transform(A, {"field": {"color": "red"}})

assert out == A(field=MyDataclass(color=Color.RED))


def test_transform_float():
value = float(math.pi)

@dataclass
class Fake:
field: Optional[float] = None

out = _transform(Fake, {"field": value})

assert out == Fake(field=value)
Loading