Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions contractions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import warnings

from ._version import __version__
Expand Down
2 changes: 1 addition & 1 deletion contractions/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "0.3.1"
__version__ = "0.3.2"

2 changes: 2 additions & 0 deletions contractions/api.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from .extension import add_custom_contraction, add_custom_dict, load_custom_from_file, load_custom_from_folder
from .processor import expand as _expand
from .processor import preview as _preview
Expand Down
2 changes: 2 additions & 0 deletions contractions/bootstrap.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from .file_loader import load_dict_data, load_list_data
from .transformer import build_apostrophe_variants, normalize_apostrophes

Expand Down
8 changes: 4 additions & 4 deletions contractions/extension.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from .file_loader import load_dict_from_file, load_dict_from_folder
from .matcher import (
_get_basic_matcher,
Expand Down Expand Up @@ -31,11 +33,9 @@ def add_custom_dict(contractions_dict: dict[str, str]) -> None:


def load_custom_from_file(filepath: str) -> None:
contractions_data = load_dict_from_file(filepath)
add_custom_dict(contractions_data)
add_custom_dict(load_dict_from_file(filepath))


def load_custom_from_folder(folderpath: str) -> None:
contractions_data = load_dict_from_folder(folderpath)
add_custom_dict(contractions_data)
add_custom_dict(load_dict_from_folder(folderpath))

8 changes: 5 additions & 3 deletions contractions/file_loader.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import json
import pkgutil

Expand All @@ -15,7 +17,7 @@ def load_dict_data(filename: str) -> dict[str, str]:
data = json.loads(json_bytes.decode("utf-8"))
validate_data_type(data, dict, filename)

return cast("dict[str, str]", data)
return cast(dict[str, str], data)


def load_list_data(filename: str) -> list[str]:
Expand All @@ -26,7 +28,7 @@ def load_list_data(filename: str) -> list[str]:
data = json.loads(json_bytes.decode("utf-8"))
validate_data_type(data, list, filename)

return cast("list[str]", data)
return cast(list[str], data)


def load_dict_from_file(filepath: str) -> dict[str, str]:
Expand All @@ -36,7 +38,7 @@ def load_dict_from_file(filepath: str) -> dict[str, str]:

contractions_data = json.loads(path.read_text(encoding="utf-8"))
validate_file_contains_dict(contractions_data, filepath)
return cast("dict[str, str]", contractions_data)
return cast(dict[str, str], contractions_data)


def load_dict_from_folder(folderpath: str) -> dict[str, str]:
Expand Down
2 changes: 2 additions & 0 deletions contractions/matcher.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from itertools import chain

from textsearch import TextSearch
Expand Down
2 changes: 2 additions & 0 deletions contractions/processor.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from .matcher import (
_get_basic_matcher,
_get_leftovers_matcher,
Expand Down
7 changes: 6 additions & 1 deletion contractions/state.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
from textsearch import TextSearch
from __future__ import annotations

from typing import TYPE_CHECKING

if TYPE_CHECKING: # pragma: no cover
from textsearch import TextSearch


class _State:
Expand Down
2 changes: 2 additions & 0 deletions contractions/transformer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from itertools import product


Expand Down
3 changes: 3 additions & 0 deletions contractions/validation.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from __future__ import annotations


def validate_string_param(value: object, param_name: str) -> None:
if not isinstance(value, str):
raise TypeError(f"{param_name} must be a string, got {type(value).__name__}")
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ ignore = [
"PLR0913",
"PLR2004",
"PLR6104",
"TC006",
]

[tool.ruff.lint.mccabe]
Expand Down
Loading