From 1e564d8b503fcaf4675b4d228f5c1bf5941d3136 Mon Sep 17 00:00:00 2001 From: Nikita Kozlovtsev Date: Tue, 16 Jul 2024 09:32:31 +0300 Subject: [PATCH] CR fixes --- README.md | 5 +++-- whole_app/settings.py | 12 +++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 7a453d1..4f41043 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/whole_app/settings.py b/whole_app/settings.py index 57b724a..a1258e0 100644 --- a/whole_app/settings.py +++ b/whole_app/settings.py @@ -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: