mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-12-15 10:57:47 -05:00
Add missing type hints to config classes. (#12402)
This commit is contained in:
parent
214f3b7d21
commit
4586119f0b
51 changed files with 263 additions and 151 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue