This commit is contained in:
Oskar Hahn 2018-02-24 16:38:17 +01:00
parent d185e05ab1
commit 6c3ae7cb4e
3 changed files with 9 additions and 9 deletions

View File

@ -3,7 +3,7 @@ import threading
import time import time
import warnings import warnings
from collections import OrderedDict, defaultdict from collections import OrderedDict, defaultdict
from typing import Any, Dict, Generator, Iterable, List, Tuple, Union from typing import Any, Dict, Generator, Iterable, List, Tuple, Union, Optional
from channels import Channel, Group from channels import Channel, Group
from channels.asgi import get_channel_layer from channels.asgi import get_channel_layer
@ -317,12 +317,12 @@ def send_data_site(message: ChannelMessageFormat) -> None:
send_or_wait(Channel(channel_name).send, {'text': json.dumps(output)}) send_or_wait(Channel(channel_name).send, {'text': json.dumps(output)})
def to_ordered_dict(d): def to_ordered_dict(d: Optional[Dict]) -> Optional[OrderedDict]:
""" """
Little helper to hash information dict in inform_*_data. Little helper to hash information dict in inform_*_data.
""" """
if isinstance(d, dict): if isinstance(d, dict):
result = OrderedDict([(key, to_ordered_dict(d[key])) for key in sorted(d.keys())]) result = OrderedDict([(key, to_ordered_dict(d[key])) for key in sorted(d.keys())]) # type: Optional[OrderedDict]
else: else:
result = d result = d
return result return result
@ -404,11 +404,11 @@ class AutoupdateBundleMiddleware:
""" """
Middleware to handle autoupdate bundling. Middleware to handle autoupdate bundling.
""" """
def __init__(self, get_response): def __init__(self, get_response: Any) -> None:
self.get_response = get_response self.get_response = get_response
# One-time configuration and initialization. # One-time configuration and initialization.
def __call__(self, request): def __call__(self, request: Any) -> Any:
thread_id = threading.get_ident() thread_id = threading.get_ident()
autoupdate_bundle[thread_id] = {} autoupdate_bundle[thread_id] = {}

View File

@ -82,6 +82,6 @@ class BinaryTemplateView(TemplateView):
""" """
Loads the specified binary template and encode it with base64. Loads the specified binary template and encode it with base64.
""" """
def load_template(self): def load_template(self) -> str:
with open(finders.find(self.template_name), 'rb') as template: with open(finders.find(self.template_name), 'rb') as template:
return base64.b64encode(template.read()) return base64.b64encode(template.read()).decode()

View File

@ -20,10 +20,10 @@ strict_optional = true
check_untyped_defs = true check_untyped_defs = true
[mypy-openslides.utils.*] [mypy-openslides.utils.*]
disallow_any = unannotated disallow_untyped_defs = true
[mypy-openslides.core.config] [mypy-openslides.core.config]
disallow_any = unannotated disallow_untyped_defs = true
[mypy-tests.*] [mypy-tests.*]
ignore_errors = true ignore_errors = true