Skip to content

Commit

Permalink
Fix for python < 3.10
Browse files Browse the repository at this point in the history
  • Loading branch information
GigantPro committed Jul 29, 2023
1 parent e019e93 commit a5e8ed2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions frozenclass/cache.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from typing import Any, Callable
from typing import Any, Callable, Optional
from datetime import time, datetime, timedelta


class CacheController:
"""The main class of the cache logic. Includes all caches logic"""
def cache(*, ttl: time | None = time(minute=10)) -> Callable: # ( TTL_end, result )
def cache(*, ttl: Optional[time] = time(minute=10)) -> Callable: # ( TTL_end, result )
"""Function-decorate for runtime caching.
The cache can either be overwritten or remain until the program terminates.
Expand Down
4 changes: 2 additions & 2 deletions frozenclass/dataparser/data_parser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any
from typing import Any, Optional, Union
import json
from copy import deepcopy

Expand Down Expand Up @@ -47,7 +47,7 @@ def _get_vars_from_saved_data(self, saved_data: dict) -> dict[str: Any]:
res[var_desc['var_name']] = get_value_by_type(var_desc['var_value'], var_desc['var_type'])
return res

def parse_file_content(self, file_name: str | None = None) -> dict[Any] | None:
def parse_file_content(self, file_name: Optional[str] = None) -> Union[dict[Any], None]:
file_name = file_name if file_name else self.filename
with open(file_name, "r", encoding="utf-8") as file:
try:
Expand Down
4 changes: 2 additions & 2 deletions frozenclass/dataparser/data_writer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from copy import deepcopy
import json
from typing import Any, Callable
from typing import Any, Callable, Optional
from random import randint
from datetime import datetime

Expand All @@ -16,7 +16,7 @@


class DataWriter:
def __init__(self, saves_path: str, save_name: str | None = None) -> None:
def __init__(self, saves_path: str, save_name: Optional[str] = None) -> None:
self.save_name = save_name
self.saves_path = saves_path

Expand Down
4 changes: 2 additions & 2 deletions frozenclass/dataparser/types_module.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import inspect
import json
from typing import Any, Callable
from typing import Any, Callable, Union

from ..exceptions import NoVar
from .const import STANDART_TYPES
Expand All @@ -15,7 +15,7 @@ def get_value_by_type(value: Any, type_: str) -> Any:
return class_obj(value)
return value

def get_type_by_saved_type(type_data: str) -> Any | None:
def get_type_by_saved_type(type_data: str) -> Union[Any, None]:
components = type_data.split(".")
if components[0] in STANDART_TYPES:
return STANDART_TYPES[components[0]]
Expand Down

0 comments on commit a5e8ed2

Please sign in to comment.