Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Fix mypy?
Browse files Browse the repository at this point in the history
  • Loading branch information
David Robertson committed May 29, 2022
1 parent 5324ad0 commit 9abb171
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions synapse/events/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import collections.abc
from typing import Iterable, Type, Union
from typing import Iterable, Type, Union, cast

import jsonschema

Expand Down Expand Up @@ -103,7 +103,12 @@ def validate_new(self, event: EventBase, config: HomeServerConfig) -> None:
except jsonschema.ValidationError as e:
if e.path:
# example: "users_default": '0' is not of type 'integer'
message = '"' + e.path[-1] + '": ' + e.message # noqa: B306
# cast safety: path entries can be integers, if we fail to validate
# items in an array. However the POWER_LEVELS_SCHEMA doesn't expect
# to see any arrays.
message = (
'"' + cast(str, e.path[-1]) + '": ' + e.message
) # noqa: B306
# jsonschema.ValidationError.message is a valid attribute
else:
# example: '0' is not of type 'integer'
Expand Down

0 comments on commit 9abb171

Please sign in to comment.