Skip to content

Commit

Permalink
Improved typing
Browse files Browse the repository at this point in the history
  • Loading branch information
xfenix committed Oct 9, 2023
1 parent 8999af0 commit 8a72baa
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
14 changes: 7 additions & 7 deletions scripts/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
from ._helpers import parse_last_git_tag, replace_tag_in_readme


PARENT_DIR: pathlib.Path = pathlib.Path(__file__).parent.parent
README_PATH: pathlib.Path = PARENT_DIR / "README.md"
PARENT_DIR: typing.Final = pathlib.Path(__file__).parent.parent
README_PATH: typing.Final = PARENT_DIR / "README.md"


def _update_dockerhub_readme() -> None:
new_content: str = re.sub(
new_content = re.sub(
r"\#\# Development.*",
r"",
README_PATH.read_text(),
Expand All @@ -28,7 +28,7 @@ def _update_readme() -> None:
from whole_app.settings import SETTINGS

new_content: str = README_PATH.read_text()
settings_schema: dict[str, typing.Any] = SETTINGS.schema()["properties"]
settings_schema: typing.Final[dict[str, typing.Any]] = SETTINGS.schema()["properties"]
pack_of_readme_lines: list[str] = []
for props in settings_schema.values():
settings_env_key: str = props["env_names"].pop().upper()
Expand Down Expand Up @@ -62,9 +62,9 @@ def _update_readme() -> None:
if __name__ == "__main__":
sys.path.append(str(PARENT_DIR.resolve()))

parser: argparse.ArgumentParser = argparse.ArgumentParser()
parser.add_argument("action")
arguments_list: argparse.Namespace = parser.parse_args()
parser_obj: typing.Final = argparse.ArgumentParser()
parser_obj.add_argument("action")
arguments_list: argparse.Namespace = parser_obj.parse_args()
match arguments_list.action:
case "update-dockerhub-readme":
_update_dockerhub_readme()
Expand Down
8 changes: 5 additions & 3 deletions whole_app/dictionaries/file.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import typing

import aiopath

from whole_app.settings import SETTINGS
Expand All @@ -22,14 +24,14 @@ async def _store_lines(self: "FileProvider", lines: list[str]) -> None:

async def save_record(self: "FileProvider", exception_word: str) -> None:
await self._user_dict_path.touch()
clean_word: str = exception_word.strip().lower()
file_content: list[str] = await self.fetch_records()
clean_word: typing.Final = exception_word.strip().lower()
file_content = await self.fetch_records()
if clean_word not in file_content:
file_content.append(clean_word)
await self._store_lines(file_content)

async def remove_record(self: "FileProvider", exception_word: str) -> None:
file_content: list[str] = await self.fetch_records()
file_content = await self.fetch_records()
if exception_word in file_content:
file_content.remove(exception_word)
await self._store_lines(file_content)
Expand Down
1 change: 0 additions & 1 deletion whole_app/spell.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

class SpellCheckService:
__slots__ = ("_input_text", "_spellcheck_engine", "_exclusion_words")

_input_text: str
_spellcheck_engine: SpellChecker
_exclusion_words: list[str]
Expand Down

0 comments on commit 8a72baa

Please sign in to comment.