diff options
author | Jonah BrĂ¼chert <jbb@kaidan.im> | 2024-03-29 02:13:57 +0100 |
---|---|---|
committer | Jonah BrĂ¼chert <jbb@kaidan.im> | 2024-03-29 02:14:22 +0100 |
commit | dcad1d5ca832ea05ababa3d38de9a82fc361f2ba (patch) | |
tree | 738e06987788744c9071020844ac8c7896db2d6d /accounts/utils/__init__.py | |
parent | 41551f9ff74c692b3db7818364a9b0966e5a08be (diff) | |
download | web-dcad1d5ca832ea05ababa3d38de9a82fc361f2ba.tar.gz web-dcad1d5ca832ea05ababa3d38de9a82fc361f2ba.tar.bz2 web-dcad1d5ca832ea05ababa3d38de9a82fc361f2ba.zip |
Enforce types in variables
Diffstat (limited to 'accounts/utils/__init__.py')
-rw-r--r-- | accounts/utils/__init__.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/accounts/utils/__init__.py b/accounts/utils/__init__.py index 6adf317..da92528 100644 --- a/accounts/utils/__init__.py +++ b/accounts/utils/__init__.py @@ -14,8 +14,11 @@ def templated(template: Optional[str] = None): def templated__(*args, **kwargs): template_name = template if template_name is None: - template_name = request.endpoint \ - .replace('.', '/') + '.html' + if request.endpoint: + template_name = request.endpoint \ + .replace('.', '/') + '.html' + else: + template_name = "error.html" ctx = f(*args, **kwargs) if ctx is None: ctx = {} @@ -30,10 +33,11 @@ class NotRegexp(Regexp): """ Like wtforms.validators.Regexp, but rejects data that DOES match the regex. """ + def __call__(self, form, field): if self.regex.match(field.data or ''): if self.message is None: - self.message = field.gettext('Invalid input.') + self.message: str = field.gettext('Invalid input.') raise ValidationError(self.message) |