diff --git a/datamimic_ce/clients/database_client.py b/datamimic_ce/clients/database_client.py index 8c17b98..47a8b46 100644 --- a/datamimic_ce/clients/database_client.py +++ b/datamimic_ce/clients/database_client.py @@ -32,7 +32,7 @@ def get_by_page_with_type(self, table_name: str, pagination: DataSourcePaginatio @abstractmethod def get_cyclic_data( - self, query: str, data_len: int, pagination: DataSourcePagination | None, cyclic: bool | None = False + self, query: str, data_len: int, pagination: DataSourcePagination, cyclic: bool = False ) -> list: """ Get cyclic data from database diff --git a/datamimic_ce/clients/rdbms_client.py b/datamimic_ce/clients/rdbms_client.py index a0bfe41..933ca91 100644 --- a/datamimic_ce/clients/rdbms_client.py +++ b/datamimic_ce/clients/rdbms_client.py @@ -25,7 +25,7 @@ class RdbmsClient(DatabaseClient): - def __init__(self, credential: RdbmsCredential, task_id: Optional[str] = None): + def __init__(self, credential: RdbmsCredential, task_id: str | None = None): self._credential = credential self._engine = None self._task_id = task_id diff --git a/datamimic_ce/converter/converter_util.py b/datamimic_ce/converter/converter_util.py index 4b500b9..7faf72d 100644 --- a/datamimic_ce/converter/converter_util.py +++ b/datamimic_ce/converter/converter_util.py @@ -13,7 +13,7 @@ class ConverterUtil: @staticmethod - def get_hash_value(hash_type: str, output_format: str, value: str, salt: Optional[str] = None) -> str: + def get_hash_value(hash_type: str, output_format: str, value: str, salt: str | None = None) -> str: hash_module_name = hash_type try: hash_module = importlib.import_module("hashlib").__getattribute__(hash_module_name) diff --git a/datamimic_ce/converter/hash_converter.py b/datamimic_ce/converter/hash_converter.py index 08d5ab0..e5b9bd0 100644 --- a/datamimic_ce/converter/hash_converter.py +++ b/datamimic_ce/converter/hash_converter.py @@ -17,7 +17,7 @@ class HashConverter(Converter): Optionally, can enhance the hash with salt """ - def __init__(self, hash_type: str, output_format: str, salt: Optional[str] = None): + def __init__(self, hash_type: str, output_format: str, salt: str | None = None): support_hashes = set(support_hash.value for support_hash in SupportHash) support_output_format = set(support_output.value for support_output in SupportOutputFormat) if hash_type.lower() not in support_hashes: diff --git a/datamimic_ce/credentials/mongodb_credential.py b/datamimic_ce/credentials/mongodb_credential.py index df86959..3ad3d17 100644 --- a/datamimic_ce/credentials/mongodb_credential.py +++ b/datamimic_ce/credentials/mongodb_credential.py @@ -18,8 +18,8 @@ class MongoDBCredential(BaseModel, Credential): host: str port: int database: str - user: Optional[str] = None - password: Optional[str] = None + user: str | None = None + password: str | None = None model_config = ConfigDict(extra="allow") diff --git a/datamimic_ce/data_sources/weighted_entity_data_source.py b/datamimic_ce/data_sources/weighted_entity_data_source.py index 3151032..3f0c380 100644 --- a/datamimic_ce/data_sources/weighted_entity_data_source.py +++ b/datamimic_ce/data_sources/weighted_entity_data_source.py @@ -6,7 +6,6 @@ import random from pathlib import Path -from typing import Optional from datamimic_ce.generators.generator import Generator from datamimic_ce.utils.file_content_storage import FileContentStorage @@ -43,7 +42,7 @@ class WeightedEntityDataSource(Generator): file_path (str): file path of "entity.wgt.ent.csv", check Example for format detail of this file type """ - def __init__(self, file_path: Path, separator: str, weight_column_name: Optional[str] = None): + def __init__(self, file_path: Path, separator: str, weight_column_name: str | None = None): file_store = FileContentStorage() weight_column = weight_column_name or "weight" self._weights, self._data_dict_list = file_store.load_file_with_custom_func( diff --git a/datamimic_ce/datamimic.py b/datamimic_ce/datamimic.py index a456e47..a4aa100 100644 --- a/datamimic_ce/datamimic.py +++ b/datamimic_ce/datamimic.py @@ -9,7 +9,6 @@ import traceback import uuid from pathlib import Path -from typing import Optional from datamimic_ce.config import settings from datamimic_ce.exporters.test_result_exporter import TestResultExporter @@ -27,11 +26,11 @@ class DataMimic: def __init__( self, descriptor_path: Path, - task_id: Optional[str] = None, - platform_props: Optional[dict[str, str]] = None, - platform_configs: Optional[dict] = None, + task_id: str | None = None, + platform_props: dict[str, str] | None = None, + platform_configs: dict | None = None, test_mode: bool = False, - args: Optional[argparse.Namespace] = None, + args: argparse.Namespace | None = None, ): """ Initialize DataMimic with descriptor_path. diff --git a/datamimic_ce/tasks/nested_key_task.py b/datamimic_ce/tasks/nested_key_task.py index a166408..211c89d 100644 --- a/datamimic_ce/tasks/nested_key_task.py +++ b/datamimic_ce/tasks/nested_key_task.py @@ -96,6 +96,7 @@ def _execute_generate(self, parent_context: GenIterContext) -> None: Create new data for nestedkey """ nestedkey_type = self._statement.type + value: dict | list if nestedkey_type == DATA_TYPE_LIST: nestedkey_len = self._determine_nestedkey_length(context=parent_context) value = [] diff --git a/datamimic_ce/tasks/task_util.py b/datamimic_ce/tasks/task_util.py index 827514e..73a9914 100644 --- a/datamimic_ce/tasks/task_util.py +++ b/datamimic_ce/tasks/task_util.py @@ -449,7 +449,7 @@ def consume_product_by_page( cache_key = f"{root_context.task_id}_{stmt.name}_{stmt.storage_id}_{stmt}" # Get or create exporters - if cache_key not in root_context._task_exporters: # TODO: mypy issue [attr-defined] + if cache_key not in root_context._task_exporters: # TODO: mypy issue [attr-defined] # Create the consumer set once consumer_set = stmt.targets.copy() # consumer_set.add(EXPORTER_PREVIEW) deactivating preview exporter for multi-process