Skip to content

Commit

Permalink
Replacing type hints for older versions of Python
Browse files Browse the repository at this point in the history
  • Loading branch information
kanewi11 committed Nov 9, 2022
1 parent c7046b0 commit 9860d08
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions reactionbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import configparser
from pathlib import Path
from sqlite3 import OperationalError
from typing import List, Dict

import uvloop
from pyrogram.errors import ReactionInvalid
Expand Down Expand Up @@ -49,26 +50,26 @@ async def make_work_dir() -> None:
WORK_DIR.mkdir()


async def get_config_files_path() -> list[Path]:
async def get_config_files_path() -> List[Path]:
"""Take all the configuration files"""
return [file for file in WORK_DIR.iterdir() if file.suffix.lower() in CONFIG_FILE_SUFFIXES]


async def config_from_ini_file(file_path: Path) -> dict:
async def config_from_ini_file(file_path: Path) -> Dict:
"""Pull the config from the *.ini file"""
config_parser = configparser.ConfigParser()
config_parser.read(file_path)
section = config_parser.sections()[0]
return {**config_parser[section]}


async def config_from_json_file(file_path: Path) -> dict:
async def config_from_json_file(file_path: Path) -> Dict:
"""Pull the config from the *.json file"""
with open(file_path) as f:
return json.load(f)


async def get_config(file_path: Path) -> dict:
async def get_config(file_path: Path) -> Dict:
"""Return the config file to the path"""
config = {
'ini': config_from_ini_file,
Expand All @@ -86,7 +87,7 @@ async def get_config(file_path: Path) -> dict:
return normalized_confing


async def create_clients(config_files: list[Path]) -> list[Client]:
async def create_clients(config_files: List[Path]) -> List[Client]:
"""
Create 'Client' instances from config files.
**If there is no name key in the config file, then the config file has the same name as the session!**
Expand Down

0 comments on commit 9860d08

Please sign in to comment.