Skip to content

Commit

Permalink
fix wrong typing (#2396)
Browse files Browse the repository at this point in the history
* fix wrong typing

* linter
  • Loading branch information
jrobinAV authored Jan 13, 2025
1 parent 349b047 commit 91ac4a5
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 3 deletions.
4 changes: 2 additions & 2 deletions taipy/core/config/data_node_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import json
from copy import copy
from datetime import timedelta, datetime
from datetime import datetime, timedelta
from typing import Any, Callable, Dict, List, Optional, Union

import numpy
Expand Down Expand Up @@ -41,7 +41,7 @@ class DataNodeConfig(Section):
"""

name = "DATA_NODE"
_ALL_TYPES = (str, int, float, bool, list, dict, tuple, set, type(None), callable, datetime, timedelta)
_ALL_TYPES = (str, int, float, bool, list, dict, tuple, set, type(None), type(callable), datetime, timedelta)
_STORAGE_TYPE_KEY = "storage_type"
_STORAGE_TYPE_VALUE_PICKLE = "pickle"
_STORAGE_TYPE_VALUE_SQL_TABLE = "sql_table"
Expand Down
66 changes: 65 additions & 1 deletion tests/core/config/checkers/test_data_node_config_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# specific language governing permissions and limitations under the License.

from copy import copy
from datetime import timedelta
from datetime import datetime, timedelta

import pytest

Expand Down Expand Up @@ -710,3 +710,67 @@ def test_check_exposed_types(self, caplog):
config._sections[DataNodeConfig.name]["default"].properties = {"exposed_type": MyCustomClass}
Config.check()
assert len(Config._collector.errors) == 0

def test_check_property_types(self, caplog):
config = Config._applied_config
Config._compile_configs()
config._sections[DataNodeConfig.name]["default"].storage_type = "pickle"
config._sections[DataNodeConfig.name]["default"].properties = {"default_data": "string"}
Config._collector = IssueCollector()
Config.check()
assert len(Config._collector.errors) == 0

config._sections[DataNodeConfig.name]["default"].properties = {"default_data": 1}
Config._collector = IssueCollector()
Config.check()
assert len(Config._collector.errors) == 0

config._sections[DataNodeConfig.name]["default"].properties = {"default_data": 1.}
Config._collector = IssueCollector()
Config.check()
assert len(Config._collector.errors) == 0

config._sections[DataNodeConfig.name]["default"].properties = {"default_data": True}
Config._collector = IssueCollector()
Config.check()
assert len(Config._collector.errors) == 0

config._sections[DataNodeConfig.name]["default"].properties = {"default_data": ["foo", "bar"]}
Config._collector = IssueCollector()
Config.check()
assert len(Config._collector.errors) == 0

config._sections[DataNodeConfig.name]["default"].properties = {"default_data": ("foo", "bar")}
Config._collector = IssueCollector()
Config.check()
assert len(Config._collector.errors) == 0

config._sections[DataNodeConfig.name]["default"].properties = {"default_data": {"foo": "bar"}}
Config._collector = IssueCollector()
Config.check()
assert len(Config._collector.errors) == 0

config._sections[DataNodeConfig.name]["default"].properties = {"default_data": {"foo", "bar"}}
Config._collector = IssueCollector()
Config.check()
assert len(Config._collector.errors) == 0

config._sections[DataNodeConfig.name]["default"].properties = {"default_data": None}
Config._collector = IssueCollector()
Config.check()
assert len(Config._collector.errors) == 0

config._sections[DataNodeConfig.name]["default"].properties = {"default_data": print}
Config._collector = IssueCollector()
Config.check()
assert len(Config._collector.errors) == 0

config._sections[DataNodeConfig.name]["default"].properties = {"default_data": datetime(2021, 7, 26)}
Config._collector = IssueCollector()
Config.check()
assert len(Config._collector.errors) == 0

config._sections[DataNodeConfig.name]["default"].properties = {"default_data": timedelta(7)}
Config._collector = IssueCollector()
Config.check()
assert len(Config._collector.errors) == 0

0 comments on commit 91ac4a5

Please sign in to comment.