Skip to content

Commit

Permalink
CR fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
NikitaKozlovtcev committed Jul 16, 2024
1 parent 91ed18d commit 1e564d8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ You can change config of the service by changing the environment variables. Here
* `SPELLCHECK_DICTIONARIES_DISABLED` switches off user dictionaries API no matter what. Default value is `False`.
* `SPELLCHECK_USERNAME_MIN_LENGTH` minimum length of username. Default value is `3`.
* `SPELLCHECK_USERNAME_MAX_LENGTH` maximum length of username. Default value is `60`.
* `SPELLCHECK_EXCLUSION_WORDS_STR` list of words which will ignored by default(string separated by comma). Default value is empty string.
* `SPELLCHECK_EXCLUSION_WORDS_SET` set of words which will ignored by default(filled from exclusion_words_str). Default value is `set()`.
* `SPELLCHECK_EXCLUSION_WORDS_STR` list of words which will ignored by default(string separated by comma). Example: 'foo, bar'. Default value is empty string.
* `SPELLCHECK_EXCLUSION_WORDS_SET` set of words which will ignored by default(filled from exclusion_words_str).
Example: '["foo", "bar"]' . Default value is `set()`.

### Deployment
Note: all docker & docker-compose variants use named volumes to store user dictionaries.
Expand Down
12 changes: 7 additions & 5 deletions whole_app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,21 +199,23 @@ class SettingsOfMicroservice(BaseSettings):
exclusion_words_str: typing.Annotated[
str,
pydantic.Field(
description="list of words which will ignored by default(string separated by comma)",
description="list of words which will ignored by default(string separated by comma). " "Example: 'foo, bar'"
),
] = ""
exclusion_words_set: typing.Annotated[
set[str],
pydantic.Field(
description="set of words which will ignored by default(filled from exclusion_words_str)",
description="""set of words which will ignored by default(filled from exclusion_words_str).
Example: '["foo", "bar"]' """,
),
] = set()

@pydantic.model_validator(mode="after")
def assemble_exclusion_words_set(self) -> "typing_extensions.Self":
self.exclusion_words_set = {
one_word.strip().lower() for one_word in self.exclusion_words_str.split(",") if one_word
}
if not self.exclusion_words_set:
self.exclusion_words_set = {
one_word.strip().lower() for one_word in self.exclusion_words_str.split(",") if one_word
}
return self

class Config:
Expand Down

0 comments on commit 1e564d8

Please sign in to comment.