mirror of https://github.com/zulip/zulip.git
zerver/lib: Remove inheritance from object.
This commit is contained in:
parent
0e71b243ce
commit
e311842a1b
|
@ -1241,7 +1241,7 @@ def do_send_messages(messages_maybe_none):
|
|||
# intermingle sending zephyr messages with other messages.
|
||||
return already_sent_ids + [message['message'].id for message in messages]
|
||||
|
||||
class UserMessageLite(object):
|
||||
class UserMessageLite:
|
||||
'''
|
||||
The Django ORM is too slow for bulk operations. This class
|
||||
is optimized for the simple use case of inserting a bunch of
|
||||
|
|
|
@ -30,7 +30,7 @@ def get_user_profiles(emails, realm):
|
|||
assert isinstance(e.messages[0], str)
|
||||
raise JsonableError(e.messages[0])
|
||||
|
||||
class Addressee(object):
|
||||
class Addressee:
|
||||
# This is really just a holder for vars that tended to be passed
|
||||
# around in a non-type-safe way before this class was introduced.
|
||||
#
|
||||
|
|
|
@ -37,7 +37,7 @@ def get_bot_handler(service_name):
|
|||
class StateHandlerError(Exception):
|
||||
pass
|
||||
|
||||
class StateHandler(object):
|
||||
class StateHandler:
|
||||
state_size_limit = 10000000 # type: int # TODO: Store this in the server configuration model.
|
||||
|
||||
def __init__(self, user_profile):
|
||||
|
@ -76,7 +76,7 @@ class StateHandler(object):
|
|||
# type: (Text) -> bool
|
||||
return is_key_in_bot_state(self.user_profile, key)
|
||||
|
||||
class EmbeddedBotHandler(object):
|
||||
class EmbeddedBotHandler:
|
||||
def __init__(self, user_profile):
|
||||
# type: (UserProfile) -> None
|
||||
# Only expose a subset of our UserProfile's functionality
|
||||
|
|
|
@ -1577,7 +1577,7 @@ def get_full_name_info(realm_id, full_names):
|
|||
}
|
||||
return dct
|
||||
|
||||
class MentionData(object):
|
||||
class MentionData:
|
||||
def __init__(self, realm_id, content):
|
||||
# type: (int, Text) -> None
|
||||
full_names = possible_mentions(content)
|
||||
|
|
|
@ -141,7 +141,7 @@ class FencedBlockPreprocessor(markdown.preprocessors.Preprocessor):
|
|||
|
||||
output = [] # type: List[Text]
|
||||
|
||||
class BaseHandler(object):
|
||||
class BaseHandler:
|
||||
def handle_line(self, line):
|
||||
# type: (Text) -> None
|
||||
raise NotImplementedError()
|
||||
|
|
|
@ -180,7 +180,7 @@ def floatify_datetime_fields(data, table):
|
|||
utc_naive = dt.replace(tzinfo=None) - dt.utcoffset()
|
||||
item[field] = (utc_naive - datetime.datetime(1970, 1, 1)).total_seconds()
|
||||
|
||||
class Config(object):
|
||||
class Config:
|
||||
'''
|
||||
A Config object configures a single table for exporting (and,
|
||||
maybe some day importing as well.
|
||||
|
|
|
@ -50,7 +50,7 @@ CATEGORIES = {
|
|||
'bots': _('Interactive bots'),
|
||||
} # type: Dict[str, str]
|
||||
|
||||
class Integration(object):
|
||||
class Integration:
|
||||
DEFAULT_LOGO_STATIC_PATH_PNG = 'static/images/integrations/logos/{name}.png'
|
||||
DEFAULT_LOGO_STATIC_PATH_SVG = 'static/images/integrations/logos/{name}.svg'
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ from logging import Logger
|
|||
|
||||
# Adapted http://djangosnippets.org/snippets/2242/ by user s29 (October 25, 2010)
|
||||
|
||||
class _RateLimitFilter(object):
|
||||
class _RateLimitFilter:
|
||||
last_error = datetime.min.replace(tzinfo=timezone_utc)
|
||||
|
||||
def filter(self, record):
|
||||
|
|
|
@ -82,7 +82,7 @@ def message_to_dict_json(message):
|
|||
# type: (Message) -> binary_type
|
||||
return MessageDict.to_dict_uncached(message)
|
||||
|
||||
class MessageDict(object):
|
||||
class MessageDict:
|
||||
@staticmethod
|
||||
def wide_dict(message):
|
||||
# type: (Message) -> Dict[str, Any]
|
||||
|
@ -413,7 +413,7 @@ class MessageDict(object):
|
|||
client_gravatar=client_gravatar,
|
||||
)
|
||||
|
||||
class ReactionDict(object):
|
||||
class ReactionDict:
|
||||
@staticmethod
|
||||
def build_dict_from_raw_db_row(row):
|
||||
# type: (Dict[str, Any]) -> Dict[str, Any]
|
||||
|
|
|
@ -19,7 +19,7 @@ from zerver.lib.queue import retry_event
|
|||
from zerver.lib.validator import check_dict, check_string
|
||||
from zerver.decorator import JsonableError
|
||||
|
||||
class OutgoingWebhookServiceInterface(object):
|
||||
class OutgoingWebhookServiceInterface:
|
||||
|
||||
def __init__(self, base_url, token, user_profile, service_name):
|
||||
# type: (Text, Text, UserProfile, Text) -> None
|
||||
|
|
|
@ -20,7 +20,7 @@ Consumer = Callable[[BlockingChannel, Basic.Deliver, pika.BasicProperties, str],
|
|||
# rabbitmq/pika's queuing system; its purpose is to just provide an
|
||||
# interface for external files to put things into queues and take them
|
||||
# out from bots without having to import pika code all over our codebase.
|
||||
class SimpleQueueClient(object):
|
||||
class SimpleQueueClient:
|
||||
def __init__(self):
|
||||
# type: () -> None
|
||||
self.log = logging.getLogger('zulip.queue')
|
||||
|
|
|
@ -21,7 +21,7 @@ rules = settings.RATE_LIMITING_RULES # type: List[Tuple[int, int]]
|
|||
|
||||
KEY_PREFIX = ''
|
||||
|
||||
class RateLimitedObject(object):
|
||||
class RateLimitedObject:
|
||||
def get_keys(self):
|
||||
# type: () -> List[Text]
|
||||
key_fragment = self.key_fragment()
|
||||
|
|
|
@ -43,11 +43,11 @@ class RequestVariableConversionError(JsonableError):
|
|||
return _("Bad value for '{var_name}': {bad_value}")
|
||||
|
||||
# Used in conjunction with @has_request_variables, below
|
||||
class REQ(object):
|
||||
class REQ:
|
||||
# NotSpecified is a sentinel value for determining whether a
|
||||
# default value was specified for a request variable. We can't
|
||||
# use None because that could be a valid, user-specified default
|
||||
class _NotSpecified(object):
|
||||
class _NotSpecified:
|
||||
pass
|
||||
NotSpecified = _NotSpecified()
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ from zerver.lib.logging_util import create_logger
|
|||
|
||||
logger = create_logger('zulip.send_email', settings.EMAIL_LOG_PATH, 'INFO')
|
||||
|
||||
class FromAddress(object):
|
||||
class FromAddress:
|
||||
SUPPORT = parseaddr(settings.ZULIP_ADMINISTRATOR)[1]
|
||||
NOREPLY = parseaddr(settings.NOREPLY_EMAIL_ADDRESS)[1]
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ def dict_with_str_keys(dct, encoding='utf-8'):
|
|||
"""applies force_str on the keys of a dict (non-recursively)"""
|
||||
return {force_str(key, encoding): value for key, value in dct.items()}
|
||||
|
||||
class ModelReprMixin(object):
|
||||
class ModelReprMixin:
|
||||
"""
|
||||
This mixin provides a python 2 and 3 compatible way of handling string representation of a model.
|
||||
When declaring a model, inherit this mixin before django.db.models.Model.
|
||||
|
|
|
@ -4,7 +4,7 @@ from typing import (Dict, List)
|
|||
from django.db import connection
|
||||
from zerver.models import Recipient
|
||||
|
||||
class StreamRecipientMap(object):
|
||||
class StreamRecipientMap:
|
||||
'''
|
||||
This class maps stream_id -> recipient_id and vice versa.
|
||||
It is useful for bulk operations. Call the populate_* methods
|
||||
|
|
|
@ -9,7 +9,7 @@ from zerver.models import (
|
|||
MutedTopic,
|
||||
)
|
||||
|
||||
class StreamTopicTarget(object):
|
||||
class StreamTopicTarget:
|
||||
'''
|
||||
This class is designed to help us move to a
|
||||
StreamTopic table or something similar. It isolates
|
||||
|
|
|
@ -257,12 +257,12 @@ def get_user_messages(user_profile):
|
|||
order_by('message')
|
||||
return [um.message for um in query]
|
||||
|
||||
class DummyHandler(object):
|
||||
class DummyHandler:
|
||||
def __init__(self):
|
||||
# type: () -> None
|
||||
allocate_handler_id(self) # type: ignore # this is a testing mock
|
||||
|
||||
class POSTRequestMock(object):
|
||||
class POSTRequestMock:
|
||||
method = "POST"
|
||||
|
||||
def __init__(self, post_data, user_profile):
|
||||
|
@ -275,7 +275,7 @@ class POSTRequestMock(object):
|
|||
self.META = {'PATH_INFO': 'test'}
|
||||
self.path = ''
|
||||
|
||||
class HostRequestMock(object):
|
||||
class HostRequestMock:
|
||||
"""A mock request object where get_host() works. Useful for testing
|
||||
routes that use Zulip's subdomains feature"""
|
||||
|
||||
|
@ -296,7 +296,7 @@ class HostRequestMock(object):
|
|||
# type: () -> Text
|
||||
return self.host
|
||||
|
||||
class MockPythonResponse(object):
|
||||
class MockPythonResponse:
|
||||
def __init__(self, text, status_code):
|
||||
# type: (Text, int) -> None
|
||||
self.text = text
|
||||
|
|
|
@ -7,7 +7,7 @@ from six.moves import map
|
|||
from typing import Dict, List, Text
|
||||
|
||||
|
||||
class SourceMap(object):
|
||||
class SourceMap:
|
||||
'''Map (line, column) pairs from generated to source file.'''
|
||||
|
||||
def __init__(self, sourcemap_dirs):
|
||||
|
|
|
@ -124,7 +124,7 @@ def resize_emoji(image_data, size=DEFAULT_EMOJI_SIZE):
|
|||
|
||||
### Common
|
||||
|
||||
class ZulipUploadBackend(object):
|
||||
class ZulipUploadBackend:
|
||||
def upload_message_image(self, uploaded_file_name, uploaded_file_size,
|
||||
content_type, file_data, user_profile, target_realm=None):
|
||||
# type: (Text, int, Optional[Text], binary_type, UserProfile, Optional[Realm]) -> Text
|
||||
|
|
|
@ -2,7 +2,7 @@ from typing import Any, Text
|
|||
from bs4 import BeautifulSoup
|
||||
|
||||
|
||||
class BaseParser(object):
|
||||
class BaseParser:
|
||||
def __init__(self, html_source):
|
||||
# type: (Text) -> None
|
||||
self._soup = BeautifulSoup(html_source, "lxml")
|
||||
|
|
|
@ -30,7 +30,7 @@ def statsd_key(val, clean_periods=False):
|
|||
|
||||
return val
|
||||
|
||||
class StatsDWrapper(object):
|
||||
class StatsDWrapper:
|
||||
"""Transparently either submit metrics to statsd
|
||||
or do nothing without erroring out"""
|
||||
|
||||
|
|
Loading…
Reference in New Issue