Skip to content

Commit

Permalink
Update __init__.py
Browse files Browse the repository at this point in the history
  • Loading branch information
RachitSharma2001 committed Jan 27, 2023
1 parent 849e72e commit a195148
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 22 deletions.
22 changes: 2 additions & 20 deletions airflow/macros/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# under the License.
from __future__ import annotations

import json
import json # noqa
import time # noqa
import uuid # noqa
from datetime import datetime, timedelta
Expand All @@ -27,7 +27,7 @@
import dateutil # noqa
from pendulum import DateTime

import airflow.utils.yaml as yaml
import airflow.utils.yaml as yaml # noqa
from airflow.utils.deprecation_tools import add_deprecated_classes

__deprecated_classes = {
Expand Down Expand Up @@ -87,21 +87,3 @@ def datetime_diff_for_humans(dt: Any, since: DateTime | None = None) -> str:
import pendulum

return pendulum.instance(dt).diff_for_humans(since)


def json_loads(data: str) -> dict[Any, Any]:
"""
Deserialize a json string.
:param data: input string representing a json or yaml object
"""
return json.loads(data)


def yaml_loads(data: str) -> dict[Any, Any]:
"""
Deserialize a yaml string.
:param data: input string representing a yaml object
"""
return yaml.safe_load(data)
4 changes: 2 additions & 2 deletions tests/macros/test_macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def test_datetime_diff_for_humans(dt, since, expected):
],
)
def test_json_loads(input_value, expected):
result = macros.json_loads(input_value)
result = macros.json.loads(input_value)
assert result == expected


Expand All @@ -118,5 +118,5 @@ def test_json_loads(input_value, expected):
],
)
def test_yaml_loads(input_value, expected):
result = macros.yaml_loads(input_value)
result = macros.yaml.safe_load(input_value)
assert result == expected

0 comments on commit a195148

Please sign in to comment.