diff options
author | Patrick Cloke <clokep@users.noreply.github.com> | 2022-04-11 12:07:23 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-11 12:07:23 -0400 |
commit | 4586119f0b0901be64f08655d3aaaef289a51bde (patch) | |
tree | 8150ea6084a6a7a034d272654720333d01b75b9f /synapse/config/captcha.py | |
parent | Enable certificate checking during complement tests (#12435) (diff) | |
download | synapse-4586119f0b0901be64f08655d3aaaef289a51bde.tar.xz |
Add missing type hints to config classes. (#12402)
Diffstat (limited to 'synapse/config/captcha.py')
-rw-r--r-- | synapse/config/captcha.py | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/synapse/config/captcha.py b/synapse/config/captcha.py index 9e48f865cc..92c603f224 100644 --- a/synapse/config/captcha.py +++ b/synapse/config/captcha.py @@ -12,15 +12,31 @@ # See the License for the specific language governing permissions and # limitations under the License. -from ._base import Config +from typing import Any + +from synapse.types import JsonDict + +from ._base import Config, ConfigError class CaptchaConfig(Config): section = "captcha" - def read_config(self, config, **kwargs): - self.recaptcha_private_key = config.get("recaptcha_private_key") - self.recaptcha_public_key = config.get("recaptcha_public_key") + def read_config(self, config: JsonDict, **kwargs: Any) -> None: + recaptcha_private_key = config.get("recaptcha_private_key") + if recaptcha_private_key is not None and not isinstance( + recaptcha_private_key, str + ): + raise ConfigError("recaptcha_private_key must be a string.") + self.recaptcha_private_key = recaptcha_private_key + + recaptcha_public_key = config.get("recaptcha_public_key") + if recaptcha_public_key is not None and not isinstance( + recaptcha_public_key, str + ): + raise ConfigError("recaptcha_public_key must be a string.") + self.recaptcha_public_key = recaptcha_public_key + self.enable_registration_captcha = config.get( "enable_registration_captcha", False ) @@ -30,7 +46,7 @@ class CaptchaConfig(Config): ) self.recaptcha_template = self.read_template("recaptcha.html") - def generate_config_section(self, **kwargs): + def generate_config_section(self, **kwargs: Any) -> str: return """\ ## Captcha ## # See docs/CAPTCHA_SETUP.md for full details of configuring this. |