Skip to content

Commit

Permalink
Merge pull request #363 from oriontvv/feature/depecate-api
Browse files Browse the repository at this point in the history
remove deprecated options
  • Loading branch information
oriontvv authored Nov 19, 2023
2 parents d9079aa + 0e499f9 commit 4c22a9d
Show file tree
Hide file tree
Showing 6 changed files with 273 additions and 310 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]


## [2.0.0] - 2023-11-19
### Removed
- [Breaking change] Remove deprecated options `flag_latin`, `ignore_latin`, `by_words`, `ignore_roman_numerals` and `ignore_uppercase`
### Changed
- Updated ruff linter version


## [1.2.0] - 2023-07-31
### Added
- Linting with ruff
Expand Down
434 changes: 262 additions & 172 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pyaspeller"
version = "1.2.0"
version = "2.0.0"
description = "Search tool typos in the text, files and websites."
authors = [
"Vasiliy Taranov <[email protected]>",
Expand Down Expand Up @@ -48,7 +48,7 @@ requests-mock = "^1.11.0"


[tool.poetry.group.dev.dependencies]
ruff = ">=0.0.277,<0.0.283"
ruff = "^0.1.6"

[build-system]
requires = [
Expand Down
32 changes: 2 additions & 30 deletions src/pyaspeller/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from .word import Word # noqa
from .yandex_speller import YandexSpeller # noqa

__version__ = "1.2.0"
__version__ = "2.0.0"
__all__ = ["main"]


Expand Down Expand Up @@ -87,12 +87,6 @@ def _create_args_parser() -> ArgumentParser:
"For example, I flew to to to Cyprus",
)

parser.add_argument(
"--flag-latin",
action="store_true",
help="celebrate words, written in Latin, as erroneous",
)

parser.add_argument(
"--ignore-tags",
action="store_true",
Expand All @@ -114,28 +108,10 @@ def _create_args_parser() -> ArgumentParser:
help="ignore words with numbers, such as avp17h4534",
)

parser.add_argument(
"--ignore-latin",
action="store_true",
help="ignore words, written in Latin, like 'madrid'",
)

parser.add_argument(
"--ignore-roman-numerals",
action="store_true",
help="ignore Roman numerals I, II, III, ...",
)

parser.add_argument(
"--ignore_uppercase",
action="store_true",
help="ignore words written in capital letters",
)

parser.add_argument(
"--ignore_urls",
action="store_true",
help="ignore Internet addresses, email " "addresses and filenames",
help="ignore Internet addresses, email addresses and filenames",
)

parser.add_argument(
Expand All @@ -158,11 +134,7 @@ def _create_speller(args: Namespace) -> YandexSpeller:
ignore_tags=args.ignore_tags,
ignore_capitalization=args.ignore_capitalization,
ignore_digits=args.ignore_digits,
ignore_latin=args.ignore_latin,
ignore_roman_numerals=args.ignore_roman_numerals,
ignore_uppercase=args.ignore_uppercase,
find_repeat_words=args.find_repeat_words,
flag_latin=args.flag_latin,
)

return speller
Expand Down
71 changes: 0 additions & 71 deletions src/pyaspeller/yandex_speller.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,7 @@ def __init__(
ignore_tags: bool = False,
ignore_capitalization: bool = False,
ignore_digits: bool = False,
ignore_latin: bool = False,
ignore_roman_numerals: bool = False,
ignore_uppercase: bool = False,
find_repeat_words: bool = False,
flag_latin: bool = False,
by_words: bool = False,
encoding: str | None = None,
) -> None:
self._lang: list[str] = []
Expand All @@ -58,13 +53,7 @@ def __init__(
self._ignore_tags = ignore_tags
self._ignore_capitalization = ignore_capitalization
self._ignore_digits = ignore_digits
self._ignore_latin = ignore_latin
self._ignore_roman_numerals = ignore_roman_numerals
self._ignore_uppercase = ignore_uppercase
self._find_repeat_words = find_repeat_words
self._flag_latin = flag_latin
self._by_words = by_words

self._max_requests = max_requests
self._is_debug = is_debug

Expand Down Expand Up @@ -185,36 +174,6 @@ def ignore_digits(self, value: bool) -> None:
"""Set ignore_digits"""
self._ignore_digits = value

@property
def ignore_latin(self) -> bool:
"""Get ignore_latin"""
return self._ignore_latin

@ignore_latin.setter
def ignore_latin(self, value: bool) -> None:
"""Set ignore_latin"""
self._ignore_latin = value

@property
def ignore_roman_numerals(self) -> bool:
"""Get ignore_roman_numerals"""
return self._ignore_roman_numerals

@ignore_roman_numerals.setter
def ignore_roman_numerals(self, value: bool) -> None:
"""Set ignore_roman_numerals"""
self._ignore_roman_numerals = value

@property
def ignore_uppercase(self) -> bool:
"""Get ignore_uppercase"""
return self._ignore_uppercase

@ignore_uppercase.setter
def ignore_uppercase(self, value: bool) -> None:
"""Set ignore_uppercase"""
self._ignore_uppercase = value

@property
def find_repeat_words(self) -> bool:
"""Get find_repeat_words"""
Expand All @@ -225,26 +184,6 @@ def find_repeat_words(self, value: bool) -> None:
"""Set find_repeat_words"""
self._find_repeat_words = value

@property
def flag_latin(self) -> bool:
"""Get flag_latin"""
return self._flag_latin

@flag_latin.setter
def flag_latin(self, value: bool) -> None:
"""Set flag_latin"""
self._flag_latin = value

@property
def by_words(self) -> bool:
"""Get by_words"""
return self._by_words

@by_words.setter
def by_words(self, value: bool) -> None:
"""Set by_words"""
self._by_words = value

@property
def max_requests(self) -> int:
"""Get max_requests"""
Expand Down Expand Up @@ -295,22 +234,12 @@ def api_options(self) -> int:
:return: api options as number
"""
options = 0
if self._ignore_uppercase:
options |= 1
if self._ignore_digits:
options |= 2
if self._ignore_urls:
options |= 4
if self._find_repeat_words:
options |= 8
if self._ignore_latin:
options |= 16
if self._flag_latin:
options |= 128
if self._by_words:
options |= 256
if self._ignore_capitalization:
options |= 512
if self._ignore_roman_numerals:
options |= 2048
return options
35 changes: 0 additions & 35 deletions tests/test_speller.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,6 @@ def test_param_ignore_tags(speller: YandexSpeller) -> None:
assert speller.ignore_tags, "Bad ignore_tags: " + str(speller.ignore_tags)


def test_param_ignore_uppercase(speller: YandexSpeller) -> None:
assert not speller.api_options & 1, "Bad ignore_uppercase option"
assert not speller.ignore_uppercase, "Bad default ignore_uppercase"
speller.ignore_uppercase = True
assert speller.api_options & 1, "Bad ignore_uppercase option"


def test_param_ignore_digits(speller: YandexSpeller) -> None:
assert not speller.api_options & 2, "Bad ignore_digits option"
assert not speller.ignore_digits, "Bad default ignore_digits"
Expand All @@ -133,41 +126,13 @@ def test_param_find_repeat_words(speller: YandexSpeller) -> None:
assert speller.api_options & 8, "Bad find_repeat_words option"


def test_param_ignore_latin(speller: YandexSpeller) -> None:
assert not speller.api_options & 16, "Bad ignore_latin option"
assert not speller.ignore_latin, "Bad default ignore_latin"
speller.ignore_latin = True
assert speller.api_options & 16, "Bad ignore_latin option"


def test_param_flag_latin(speller: YandexSpeller) -> None:
assert not speller.api_options & 128, "Bad flag_latin option"
assert not speller.flag_latin, "Bad default flag_latin"
speller.flag_latin = True
assert speller.api_options & 128, "Bad flag_latin option"


def test_param_by_words(speller: YandexSpeller) -> None:
assert not speller.api_options & 256, "Bad by_words option"
assert not speller.by_words, "Bad default by_words"
speller.by_words = True
assert speller.api_options & 256, "Bad by_words option"


def test_param_ignore_capitalization(speller: YandexSpeller) -> None:
assert not speller.api_options & 512, "Bad ignore_capitalization option"
assert not speller.ignore_capitalization, "Bad default ignore_capitalization"
speller.ignore_capitalization = True
assert speller.api_options & 512, "Bad ignore_capitalization option"


def test_param_ignore_roman_numerals(speller: YandexSpeller) -> None:
assert not speller.api_options & 2048, "Bad ignore_roman_numerals option"
assert not speller.ignore_roman_numerals, "Bad default ignore_capitalization"
speller.ignore_roman_numerals = True
assert speller.api_options & 2048, "Bad ignore_roman_numerals option"


def test_spelled(speller: YandexSpeller) -> None:
result = speller.spelled("tesst message")
assert result == "test message"
Expand Down

0 comments on commit 4c22a9d

Please sign in to comment.