zerver: Remove inheritance from object.

This commit is contained in:
rht
2017-11-05 11:53:59 +01:00
committed by showell
parent 2ceb0b45b3
commit 8990b1046d
6 changed files with 28 additions and 28 deletions

View File

@@ -50,7 +50,7 @@ ReturnT = TypeVar('ReturnT')
webhook_logger = create_logger( webhook_logger = create_logger(
"zulip.zerver.webhooks", settings.API_KEY_ONLY_WEBHOOK_LOG_PATH, 'DEBUG') "zulip.zerver.webhooks", settings.API_KEY_ONLY_WEBHOOK_LOG_PATH, 'DEBUG')
class _RespondAsynchronously(object): class _RespondAsynchronously:
pass pass
# Return RespondAsynchronously from an @asynchronous view if the # Return RespondAsynchronously from an @asynchronous view if the

View File

@@ -300,7 +300,7 @@ class Realm(models.Model):
# type: () -> bool # type: () -> bool
return self.is_zephyr_mirror_realm return self.is_zephyr_mirror_realm
class Meta(object): class Meta:
permissions = ( permissions = (
('administer', "Administer a realm"), ('administer', "Administer a realm"),
('api_super_user', "Can send messages as other users for mirroring"), ('api_super_user', "Can send messages as other users for mirroring"),
@@ -324,7 +324,7 @@ class RealmDomain(models.Model):
domain = models.CharField(max_length=80, db_index=True) # type: Text domain = models.CharField(max_length=80, db_index=True) # type: Text
allow_subdomains = models.BooleanField(default=False) allow_subdomains = models.BooleanField(default=False)
class Meta(object): class Meta:
unique_together = ("realm", "domain") unique_together = ("realm", "domain")
# These functions should only be used on email addresses that have # These functions should only be used on email addresses that have
@@ -381,7 +381,7 @@ class RealmEmoji(models.Model):
PATH_ID_TEMPLATE = "{realm_id}/emoji/{emoji_file_name}" PATH_ID_TEMPLATE = "{realm_id}/emoji/{emoji_file_name}"
class Meta(object): class Meta:
unique_together = ("realm", "name") unique_together = ("realm", "name")
def __str__(self): def __str__(self):
@@ -440,7 +440,7 @@ class RealmFilter(models.Model):
pattern = models.TextField(validators=[filter_pattern_validator]) # type: Text pattern = models.TextField(validators=[filter_pattern_validator]) # type: Text
url_format_string = models.TextField(validators=[URLValidator(), filter_format_validator]) # type: Text url_format_string = models.TextField(validators=[URLValidator(), filter_format_validator]) # type: Text
class Meta(object): class Meta:
unique_together = ("realm", "pattern") unique_together = ("realm", "pattern")
def __str__(self): def __str__(self):
@@ -853,7 +853,7 @@ class AbstractPushDeviceToken(models.Model):
# [optional] Contains the app id of the device if it is an iOS device # [optional] Contains the app id of the device if it is an iOS device
ios_app_id = models.TextField(null=True) # type: Optional[Text] ios_app_id = models.TextField(null=True) # type: Optional[Text]
class Meta(object): class Meta:
abstract = True abstract = True
class PushDeviceToken(AbstractPushDeviceToken): class PushDeviceToken(AbstractPushDeviceToken):
@@ -900,7 +900,7 @@ class Stream(models.Model):
# All streams are private in Zephyr mirroring realms. # All streams are private in Zephyr mirroring realms.
return not self.invite_only and not self.is_in_zephyr_realm return not self.invite_only and not self.is_in_zephyr_realm
class Meta(object): class Meta:
unique_together = ("name", "realm") unique_together = ("name", "realm")
# This is stream information that is sent to clients # This is stream information that is sent to clients
@@ -929,7 +929,7 @@ class Recipient(models.Model):
STREAM = 2 STREAM = 2
HUDDLE = 3 HUDDLE = 3
class Meta(object): class Meta:
unique_together = ("type", "type_id") unique_together = ("type", "type_id")
# N.B. If we used Django's choice=... we would get this for free (kinda) # N.B. If we used Django's choice=... we would get this for free (kinda)
@@ -954,7 +954,7 @@ class MutedTopic(models.Model):
recipient = models.ForeignKey(Recipient, on_delete=CASCADE) recipient = models.ForeignKey(Recipient, on_delete=CASCADE)
topic_name = models.CharField(max_length=MAX_SUBJECT_LENGTH) topic_name = models.CharField(max_length=MAX_SUBJECT_LENGTH)
class Meta(object): class Meta:
unique_together = ('user_profile', 'stream', 'topic_name') unique_together = ('user_profile', 'stream', 'topic_name')
def __str__(self): def __str__(self):
@@ -1121,7 +1121,7 @@ class AbstractMessage(models.Model):
has_image = models.BooleanField(default=False, db_index=True) # type: bool has_image = models.BooleanField(default=False, db_index=True) # type: bool
has_link = models.BooleanField(default=False, db_index=True) # type: bool has_link = models.BooleanField(default=False, db_index=True) # type: bool
class Meta(object): class Meta:
abstract = True abstract = True
def __str__(self): def __str__(self):
@@ -1267,7 +1267,7 @@ class Reaction(models.Model):
reaction_type = models.CharField(default=UNICODE_EMOJI, choices=REACTION_TYPES, max_length=30) # type: Text reaction_type = models.CharField(default=UNICODE_EMOJI, choices=REACTION_TYPES, max_length=30) # type: Text
class Meta(object): class Meta:
unique_together = ("user_profile", "message", "emoji_name") unique_together = ("user_profile", "message", "emoji_name")
@staticmethod @staticmethod
@@ -1300,7 +1300,7 @@ class AbstractUserMessage(models.Model):
'has_alert_word', "historical"] 'has_alert_word', "historical"]
flags = BitField(flags=ALL_FLAGS, default=0) # type: BitHandler flags = BitField(flags=ALL_FLAGS, default=0) # type: BitHandler
class Meta(object): class Meta:
abstract = True abstract = True
unique_together = ("user_profile", "message") unique_together = ("user_profile", "message")
@@ -1371,7 +1371,7 @@ class AbstractAttachment(models.Model):
db_index=True) # type: datetime.datetime db_index=True) # type: datetime.datetime
size = models.IntegerField(null=True) # type: Optional[int] size = models.IntegerField(null=True) # type: Optional[int]
class Meta(object): class Meta:
abstract = True abstract = True
def __str__(self): def __str__(self):
@@ -1453,7 +1453,7 @@ class Subscription(models.Model):
# above. # above.
notifications = models.BooleanField(default=False) # type: bool notifications = models.BooleanField(default=False) # type: bool
class Meta(object): class Meta:
unique_together = ("user_profile", "recipient") unique_together = ("user_profile", "recipient")
def __str__(self): def __str__(self):
@@ -1605,7 +1605,7 @@ class UserActivity(models.Model):
count = models.IntegerField() # type: int count = models.IntegerField() # type: int
last_visit = models.DateTimeField('last visit') # type: datetime.datetime last_visit = models.DateTimeField('last visit') # type: datetime.datetime
class Meta(object): class Meta:
unique_together = ("user_profile", "client", "query") unique_together = ("user_profile", "client", "query")
class UserActivityInterval(models.Model): class UserActivityInterval(models.Model):
@@ -1790,14 +1790,14 @@ class UserPresence(models.Model):
return status_val return status_val
class Meta(object): class Meta:
unique_together = ("user_profile", "client") unique_together = ("user_profile", "client")
class DefaultStream(models.Model): class DefaultStream(models.Model):
realm = models.ForeignKey(Realm, on_delete=CASCADE) # type: Realm realm = models.ForeignKey(Realm, on_delete=CASCADE) # type: Realm
stream = models.ForeignKey(Stream, on_delete=CASCADE) # type: Stream stream = models.ForeignKey(Stream, on_delete=CASCADE) # type: Stream
class Meta(object): class Meta:
unique_together = ("realm", "stream") unique_together = ("realm", "stream")
class DefaultStreamGroup(models.Model): class DefaultStreamGroup(models.Model):
@@ -1806,7 +1806,7 @@ class DefaultStreamGroup(models.Model):
realm = models.ForeignKey(Realm, on_delete=CASCADE) # type: Realm realm = models.ForeignKey(Realm, on_delete=CASCADE) # type: Realm
streams = models.ManyToManyField('Stream') # type: Manager streams = models.ManyToManyField('Stream') # type: Manager
class Meta(object): class Meta:
unique_together = ("realm", "name") unique_together = ("realm", "name")
def to_dict(self): def to_dict(self):
@@ -1822,7 +1822,7 @@ class AbstractScheduledJob(models.Model):
# JSON representation of arguments to consumer # JSON representation of arguments to consumer
data = models.TextField() # type: Text data = models.TextField() # type: Text
class Meta(object): class Meta:
abstract = True abstract = True
class ScheduledEmail(AbstractScheduledJob): class ScheduledEmail(AbstractScheduledJob):
@@ -1876,7 +1876,7 @@ class UserHotspot(models.Model):
hotspot = models.CharField(max_length=30) # type: Text hotspot = models.CharField(max_length=30) # type: Text
timestamp = models.DateTimeField(default=timezone_now) # type: datetime.datetime timestamp = models.DateTimeField(default=timezone_now) # type: datetime.datetime
class Meta(object): class Meta:
unique_together = ("user", "hotspot") unique_together = ("user", "hotspot")
class CustomProfileField(models.Model): class CustomProfileField(models.Model):
@@ -1903,7 +1903,7 @@ class CustomProfileField(models.Model):
field_type = models.PositiveSmallIntegerField(choices=FIELD_TYPE_CHOICES, field_type = models.PositiveSmallIntegerField(choices=FIELD_TYPE_CHOICES,
default=SHORT_TEXT) # type: int default=SHORT_TEXT) # type: int
class Meta(object): class Meta:
unique_together = ('realm', 'name') unique_together = ('realm', 'name')
def as_dict(self): def as_dict(self):
@@ -1923,7 +1923,7 @@ class CustomProfileFieldValue(models.Model):
field = models.ForeignKey(CustomProfileField, on_delete=CASCADE) # type: CustomProfileField field = models.ForeignKey(CustomProfileField, on_delete=CASCADE) # type: CustomProfileField
value = models.TextField() # type: Text value = models.TextField() # type: Text
class Meta(object): class Meta:
unique_together = ('user_profile', 'field') unique_together = ('user_profile', 'field')
# Interfaces for services # Interfaces for services
@@ -1996,5 +1996,5 @@ class BotUserStateData(models.Model):
key = models.TextField(db_index=True) # type: Text key = models.TextField(db_index=True) # type: Text
value = models.TextField() # type: Text value = models.TextField() # type: Text
class Meta(object): class Meta:
unique_together = ("bot_profile", "key") unique_together = ("bot_profile", "key")

View File

@@ -10,7 +10,7 @@ from pipeline.storage import PipelineMixin
from zerver.lib.str_utils import force_str from zerver.lib.str_utils import force_str
class AddHeaderMixin(object): class AddHeaderMixin:
def post_process(self, paths, dry_run=False, **kwargs): def post_process(self, paths, dry_run=False, **kwargs):
# type: (Dict[str, Tuple[ZulipStorage, str]], bool, **Any) -> List[Tuple[str, str, bool]] # type: (Dict[str, Tuple[ZulipStorage, str]], bool, **Any) -> List[Tuple[str, str, bool]]
if dry_run: if dry_run:
@@ -57,7 +57,7 @@ class AddHeaderMixin(object):
return list(ret_dict.values()) return list(ret_dict.values())
class RemoveUnminifiedFilesMixin(object): class RemoveUnminifiedFilesMixin:
def post_process(self, paths, dry_run=False, **kwargs): def post_process(self, paths, dry_run=False, **kwargs):
# type: (Dict[str, Tuple[ZulipStorage, str]], bool, **Any) -> List[Tuple[str, str, bool]] # type: (Dict[str, Tuple[ZulipStorage, str]], bool, **Any) -> List[Tuple[str, str, bool]]
if dry_run: if dry_run:

View File

@@ -74,7 +74,7 @@ Query = Any # TODO: Should be Select, but sqlalchemy stubs are busted
ConditionTransform = Any # TODO: should be Callable[[ColumnElement], ColumnElement], but sqlalchemy stubs are busted ConditionTransform = Any # TODO: should be Callable[[ColumnElement], ColumnElement], but sqlalchemy stubs are busted
# When you add a new operator to this, also update zerver/lib/narrow.py # When you add a new operator to this, also update zerver/lib/narrow.py
class NarrowBuilder(object): class NarrowBuilder:
''' '''
Build up a SQLAlchemy query to find messages matching a narrow. Build up a SQLAlchemy query to find messages matching a narrow.
''' '''

View File

@@ -18,7 +18,7 @@ ALERT_CLEAR = 'clear'
ALERT_VIOLATION = 'violations' ALERT_VIOLATION = 'violations'
SNAPSHOT = 'image_url' SNAPSHOT = 'image_url'
class LibratoWebhookParser(object): class LibratoWebhookParser:
ALERT_URL_TEMPLATE = "https://metrics.librato.com/alerts#/{alert_id}" ALERT_URL_TEMPLATE = "https://metrics.librato.com/alerts#/{alert_id}"
def __init__(self, payload: Dict[str, Any], attachments: List[Dict[str, Any]]) -> None: def __init__(self, payload: Dict[str, Any], attachments: List[Dict[str, Any]]) -> None:

View File

@@ -122,7 +122,7 @@ def retry_send_email_failures(func):
return wrapper return wrapper
class QueueProcessingWorker(object): class QueueProcessingWorker:
queue_name = None # type: str queue_name = None # type: str
def __init__(self): def __init__(self):