Skip to content

Commit

Permalink
All fixed?
Browse files Browse the repository at this point in the history
  • Loading branch information
xfenix committed Sep 26, 2023
1 parent 55facd1 commit c14f8d4
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 42 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,6 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/

# More various
.DS_Store
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ test-in-docker:
docker run -t spellcheck-microservice bash -c "COVERAGE_FILE=/tmp/junk.coverage pytest . -n3"

lint:
ruff .
ruff . --no-fix
mypy .
vulture whole_app --min-confidence 100
black . --check
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ line-length = 120
line-length = 120
fix = true
select = ["ALL"]
ignore = ["D1", "D203", "D213", "FA102", "I", "ANN101"]
ignore = ["D1", "D203", "D213", "FA102", "ANN101"]

[tool.ruff.isort]
lines-after-imports = 2
Expand Down
6 changes: 1 addition & 5 deletions scripts/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@ def _update_readme() -> None:
""
if "exclusiveMinimum" not in props
else f", allowed values from `{props['exclusiveMinimum'] + 1}`"
+ (
f"to `{props['exclusiveMaximum'] - 1}`"
if "exclusiveMaximum" in props
else ""
)
+ (f"to `{props['exclusiveMaximum'] - 1}`" if "exclusiveMaximum" in props else "")
)
pack_of_readme_lines.append(
f'`{settings_env_key}` {props["description"].rstrip(".")}. '
Expand Down
11 changes: 2 additions & 9 deletions scripts/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,11 @@ def parse_last_git_tag() -> str:
git_tags_list: typing.Final = shlex.split(
"git rev-list --tags --max-count=1",
)
last_tag_hash: typing.Final = (
subprocess.check_output(git_tags_list).strip().decode() # noqa: S603
)
last_tag_hash: typing.Final = subprocess.check_output(git_tags_list).strip().decode() # noqa: S603
git_tag_description: typing.Final = shlex.split(
f"git describe --tags {last_tag_hash}",
)
return (
subprocess.check_output(git_tag_description) # noqa: S603
.strip()
.decode()
.lstrip("v")
)
return subprocess.check_output(git_tag_description).strip().decode().lstrip("v") # noqa: S603
return last_tag_from_environment.lstrip("v")


Expand Down
15 changes: 5 additions & 10 deletions tests/test_dict_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ def test_add_to_dict(
) -> None:
fake_user_name: typing.Final = faker_obj.user_name()
fake_exc_word: typing.Final = faker_obj.word()
path_to_dict_file: typing.Final = (
SETTINGS.dictionaries_path.joinpath( # pylint: disable=no-member
fake_user_name,
)
path_to_dict_file: typing.Final = SETTINGS.dictionaries_path.joinpath( # pylint: disable=no-member
fake_user_name,
)
server_response = app_client.post(
DICT_ENDPOINT,
Expand All @@ -60,10 +58,8 @@ def test_remove_from_user_dict(
) -> None:
fake_exc_word: typing.Final = faker_obj.word()
fake_user_name: typing.Final = faker_obj.user_name()
path_to_dict_file: typing.Final = (
SETTINGS.dictionaries_path.joinpath( # pylint: disable=no-member
fake_user_name,
)
path_to_dict_file: typing.Final = SETTINGS.dictionaries_path.joinpath( # pylint: disable=no-member
fake_user_name,
)
path_to_dict_file.touch()
path_to_dict_file.write_text(fake_exc_word)
Expand Down Expand Up @@ -141,8 +137,7 @@ def test_wrong_api_key(self: "TestVarious") -> None:
exception_word="test",
).dict(),
headers={
SETTINGS.api_key_header_name: SETTINGS.api_key
+ "wrongTrashKekJunk --- 5000",
SETTINGS.api_key_header_name: SETTINGS.api_key + "wrongTrashKekJunk --- 5000",
},
)
assert server_response.status_code == 401
3 changes: 2 additions & 1 deletion tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
import importlib
import os
import runpy
from typing import TYPE_CHECKING
import typing
from typing import TYPE_CHECKING

from fastapi.testclient import TestClient

from whole_app import views
from whole_app.settings import SETTINGS, SettingsOfMicroservice


if TYPE_CHECKING:
import faker

Expand Down
7 changes: 3 additions & 4 deletions tests/test_spell_views.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
# pylint: disable=redefined-outer-name
"""Basic test for views."""
import random
import typing

import pytest
from requests.models import Response as RequestsResponse

from ._fixtures import BAD_PAYLOAD
from whole_app import models
from whole_app.settings import SETTINGS, StorageProviders

from ._fixtures import BAD_PAYLOAD
from requests.models import Response as RequestsResponse

if typing.TYPE_CHECKING:
from fastapi.testclient import TestClient
import faker
from fastapi.testclient import TestClient


RUSSIAN_LETTERS: typing.Final = "абвгдежзийклмнопрстуфхцчшщъыьэюяё"
Expand Down
1 change: 1 addition & 0 deletions tests/test_various_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from whole_app.settings import SETTINGS


if typing.TYPE_CHECKING:
from fastapi.testclient import TestClient

Expand Down
6 changes: 1 addition & 5 deletions whole_app/dictionaries/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,5 @@ async def remove_record(self: "FileProvider", exception_word: str) -> None:

async def fetch_records(self: "FileProvider") -> list[str]:
if await self._user_dict_path.exists():
return [
one_line.strip()
for one_line in (await self._user_dict_path.read_text()).split("\n")
if one_line
]
return [one_line.strip() for one_line in (await self._user_dict_path.read_text()).split("\n") if one_line]
return []
4 changes: 1 addition & 3 deletions whole_app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
from pydantic_settings import BaseSettings


PATH_TO_PYPROJECT: typing.Final = (
pathlib.Path(__file__).parent.parent / "pyproject.toml"
)
PATH_TO_PYPROJECT: typing.Final = pathlib.Path(__file__).parent.parent / "pyproject.toml"
AvailableLanguagesType = typing.Literal[
"ru_RU",
"en_US",
Expand Down
4 changes: 1 addition & 3 deletions whole_app/spell.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ def get_memorized_suggestions(word_spellcheck_result: SpellChecker) -> list[str]
misspelled_suggestions = word_spellcheck_result.suggest()
_MISSPELED_CACHE[word_spellcheck_result.word] = misspelled_suggestions
return (
misspelled_suggestions[: SETTINGS.max_suggestions]
if SETTINGS.max_suggestions
else misspelled_suggestions
misspelled_suggestions[: SETTINGS.max_suggestions] if SETTINGS.max_suggestions else misspelled_suggestions
)

def run_check(self: "SpellCheckService") -> list[models.OneCorrection]:
Expand Down

0 comments on commit c14f8d4

Please sign in to comment.