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

Commit

Permalink
Stop sub-classing object (#8249)
Browse files Browse the repository at this point in the history
  • Loading branch information
clokep authored Sep 4, 2020
1 parent 9f8abdc commit c619253
Show file tree
Hide file tree
Showing 168 changed files with 293 additions and 292 deletions.
1 change: 1 addition & 0 deletions changelog.d/8249.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Stop sub-classing from object.
6 changes: 3 additions & 3 deletions contrib/cmdclient/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from twisted.web.http_headers import Headers


class HttpClient(object):
class HttpClient:
""" Interface for talking json over http
"""

Expand Down Expand Up @@ -169,7 +169,7 @@ def sleep(self, seconds):
return d


class _RawProducer(object):
class _RawProducer:
def __init__(self, data):
self.data = data
self.body = data
Expand All @@ -186,7 +186,7 @@ def stopProducing(self):
pass


class _JsonProducer(object):
class _JsonProducer:
""" Used by the twisted http client to create the HTTP body from json
"""

Expand Down
2 changes: 1 addition & 1 deletion contrib/experiments/cursesio.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def close(self):
curses.endwin()


class Callback(object):
class Callback:
def __init__(self, stdio):
self.stdio = stdio

Expand Down
4 changes: 2 additions & 2 deletions contrib/experiments/test_messaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def excpetion_errback(failure):
logging.exception(failure)


class InputOutput(object):
class InputOutput:
""" This is responsible for basic I/O so that a user can interact with
the example app.
"""
Expand Down Expand Up @@ -132,7 +132,7 @@ def emit(self, record):
self.io.print_log(msg)


class Room(object):
class Room:
""" Used to store (in memory) the current membership state of a room, and
which home servers we should send PDUs associated with the room to.
"""
Expand Down
2 changes: 1 addition & 1 deletion scripts-dev/hash_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from synapse.storage.signatures import SignatureStore


class Store(object):
class Store:
_get_pdu_tuples = PduStore.__dict__["_get_pdu_tuples"]
_get_pdu_content_hashes_txn = SignatureStore.__dict__["_get_pdu_content_hashes_txn"]
_get_prev_pdu_hashes_txn = SignatureStore.__dict__["_get_prev_pdu_hashes_txn"]
Expand Down
2 changes: 1 addition & 1 deletion synapse/api/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class _InvalidMacaroonException(Exception):
pass


class Auth(object):
class Auth:
"""
FIXME: This class contains a mix of functions for authenticating users
of our client-server API and authenticating events added to room graphs.
Expand Down
2 changes: 1 addition & 1 deletion synapse/api/auth_blocking.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
logger = logging.getLogger(__name__)


class AuthBlocking(object):
class AuthBlocking:
def __init__(self, hs):
self.store = hs.get_datastore()

Expand Down
26 changes: 13 additions & 13 deletions synapse/api/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
MAX_USERID_LENGTH = 255


class Membership(object):
class Membership:

"""Represents the membership states of a user in a room."""

Expand All @@ -40,22 +40,22 @@ class Membership(object):
LIST = (INVITE, JOIN, KNOCK, LEAVE, BAN)


class PresenceState(object):
class PresenceState:
"""Represents the presence state of a user."""

OFFLINE = "offline"
UNAVAILABLE = "unavailable"
ONLINE = "online"


class JoinRules(object):
class JoinRules:
PUBLIC = "public"
KNOCK = "knock"
INVITE = "invite"
PRIVATE = "private"


class LoginType(object):
class LoginType:
PASSWORD = "m.login.password"
EMAIL_IDENTITY = "m.login.email.identity"
MSISDN = "m.login.msisdn"
Expand All @@ -65,7 +65,7 @@ class LoginType(object):
DUMMY = "m.login.dummy"


class EventTypes(object):
class EventTypes:
Member = "m.room.member"
Create = "m.room.create"
Tombstone = "m.room.tombstone"
Expand Down Expand Up @@ -96,17 +96,17 @@ class EventTypes(object):
Presence = "m.presence"


class RejectedReason(object):
class RejectedReason:
AUTH_ERROR = "auth_error"


class RoomCreationPreset(object):
class RoomCreationPreset:
PRIVATE_CHAT = "private_chat"
PUBLIC_CHAT = "public_chat"
TRUSTED_PRIVATE_CHAT = "trusted_private_chat"


class ThirdPartyEntityKind(object):
class ThirdPartyEntityKind:
USER = "user"
LOCATION = "location"

Expand All @@ -115,7 +115,7 @@ class ThirdPartyEntityKind(object):
ServerNoticeLimitReached = "m.server_notice.usage_limit_reached"


class UserTypes(object):
class UserTypes:
"""Allows for user type specific behaviour. With the benefit of hindsight
'admin' and 'guest' users should also be UserTypes. Normal users are type None
"""
Expand All @@ -125,7 +125,7 @@ class UserTypes(object):
ALL_USER_TYPES = (SUPPORT, BOT)


class RelationTypes(object):
class RelationTypes:
"""The types of relations known to this server.
"""

Expand All @@ -134,14 +134,14 @@ class RelationTypes(object):
REFERENCE = "m.reference"


class LimitBlockingTypes(object):
class LimitBlockingTypes:
"""Reasons that a server may be blocked"""

MONTHLY_ACTIVE_USER = "monthly_active_user"
HS_DISABLED = "hs_disabled"


class EventContentFields(object):
class EventContentFields:
"""Fields found in events' content, regardless of type."""

# Labels for the event, cf https://github.com/matrix-org/matrix-doc/pull/2326
Expand All @@ -152,6 +152,6 @@ class EventContentFields(object):
SELF_DESTRUCT_AFTER = "org.matrix.self_destruct_after"


class RoomEncryptionAlgorithms(object):
class RoomEncryptionAlgorithms:
MEGOLM_V1_AES_SHA2 = "m.megolm.v1.aes-sha2"
DEFAULT = MEGOLM_V1_AES_SHA2
2 changes: 1 addition & 1 deletion synapse/api/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
logger = logging.getLogger(__name__)


class Codes(object):
class Codes:
UNRECOGNIZED = "M_UNRECOGNIZED"
UNAUTHORIZED = "M_UNAUTHORIZED"
FORBIDDEN = "M_FORBIDDEN"
Expand Down
6 changes: 3 additions & 3 deletions synapse/api/filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def matrix_user_id_validator(user_id_str):
return UserID.from_string(user_id_str)


class Filtering(object):
class Filtering:
def __init__(self, hs):
super(Filtering, self).__init__()
self.store = hs.get_datastore()
Expand Down Expand Up @@ -168,7 +168,7 @@ def check_valid_filter(self, user_filter_json):
raise SynapseError(400, str(e))


class FilterCollection(object):
class FilterCollection:
def __init__(self, filter_json):
self._filter_json = filter_json

Expand Down Expand Up @@ -249,7 +249,7 @@ def blocks_all_room_timeline(self):
)


class Filter(object):
class Filter:
def __init__(self, filter_json):
self.filter_json = filter_json

Expand Down
2 changes: 1 addition & 1 deletion synapse/api/ratelimiting.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from synapse.util import Clock


class Ratelimiter(object):
class Ratelimiter:
"""
Ratelimit actions marked by arbitrary keys.
Expand Down
10 changes: 5 additions & 5 deletions synapse/api/room_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import attr


class EventFormatVersions(object):
class EventFormatVersions:
"""This is an internal enum for tracking the version of the event format,
independently from the room version.
"""
Expand All @@ -35,20 +35,20 @@ class EventFormatVersions(object):
}


class StateResolutionVersions(object):
class StateResolutionVersions:
"""Enum to identify the state resolution algorithms"""

V1 = 1 # room v1 state res
V2 = 2 # MSC1442 state res: room v2 and later


class RoomDisposition(object):
class RoomDisposition:
STABLE = "stable"
UNSTABLE = "unstable"


@attr.s(slots=True, frozen=True)
class RoomVersion(object):
class RoomVersion:
"""An object which describes the unique attributes of a room version."""

identifier = attr.ib() # str; the identifier for this version
Expand All @@ -69,7 +69,7 @@ class RoomVersion(object):
limit_notifications_power_levels = attr.ib(type=bool)


class RoomVersions(object):
class RoomVersions:
V1 = RoomVersion(
"1",
RoomDisposition.STABLE,
Expand Down
2 changes: 1 addition & 1 deletion synapse/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
LEGACY_MEDIA_PREFIX = "/_matrix/media/v1"


class ConsentURIBuilder(object):
class ConsentURIBuilder:
def __init__(self, hs_config):
"""
Args:
Expand Down
4 changes: 2 additions & 2 deletions synapse/app/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def install_dns_limiter(reactor, max_dns_requests_in_flight=100):
reactor.installNameResolver(new_resolver)


class _LimitedHostnameResolver(object):
class _LimitedHostnameResolver:
"""Wraps a IHostnameResolver, limiting the number of in-flight DNS lookups.
"""

Expand Down Expand Up @@ -409,7 +409,7 @@ def _resolve(
yield deferred


class _DeferredResolutionReceiver(object):
class _DeferredResolutionReceiver:
"""Wraps a IResolutionReceiver and simply resolves the given deferred when
resolution is complete
"""
Expand Down
2 changes: 1 addition & 1 deletion synapse/app/generic_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ def on_remote_server_up(self, server: str):
self.send_handler.wake_destination(server)


class FederationSenderHandler(object):
class FederationSenderHandler:
"""Processes the fedration replication stream
This class is only instantiate on the worker responsible for sending outbound
Expand Down
6 changes: 3 additions & 3 deletions synapse/appservice/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
logger = logging.getLogger(__name__)


class ApplicationServiceState(object):
class ApplicationServiceState:
DOWN = "down"
UP = "up"


class AppServiceTransaction(object):
class AppServiceTransaction:
"""Represents an application service transaction."""

def __init__(self, service, id, events):
Expand Down Expand Up @@ -64,7 +64,7 @@ async def complete(self, store: "DataStore") -> None:
await store.complete_appservice_txn(service=self.service, txn_id=self.id)


class ApplicationService(object):
class ApplicationService:
"""Defines an application service. This definition is mostly what is
provided to the /register AS API.
Expand Down
8 changes: 4 additions & 4 deletions synapse/appservice/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
logger = logging.getLogger(__name__)


class ApplicationServiceScheduler(object):
class ApplicationServiceScheduler:
""" Public facing API for this module. Does the required DI to tie the
components together. This also serves as the "event_pool", which in this
case is a simple array.
Expand Down Expand Up @@ -86,7 +86,7 @@ def submit_event_for_as(self, service, event):
self.queuer.enqueue(service, event)


class _ServiceQueuer(object):
class _ServiceQueuer:
"""Queue of events waiting to be sent to appservices.
Groups events into transactions per-appservice, and sends them on to the
Expand Down Expand Up @@ -133,7 +133,7 @@ async def _send_request(self, service):
self.requests_in_flight.discard(service.id)


class _TransactionController(object):
class _TransactionController:
"""Transaction manager.
Builds AppServiceTransactions and runs their lifecycle. Also starts a Recoverer
Expand Down Expand Up @@ -209,7 +209,7 @@ async def _is_service_up(self, service):
return state == ApplicationServiceState.UP or state is None


class _Recoverer(object):
class _Recoverer:
"""Manages retries and backoff for a DOWN appservice.
We have one of these for each appservice which is currently considered DOWN.
Expand Down
4 changes: 2 additions & 2 deletions synapse/config/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def path_exists(file_path):
return False


class Config(object):
class Config:
"""
A configuration section, containing configuration keys and values.
Expand Down Expand Up @@ -283,7 +283,7 @@ def mxc_to_http_filter(value, width, height, resize_method="crop"):
return mxc_to_http_filter


class RootConfig(object):
class RootConfig:
"""
Holder of an application's configuration.
Expand Down
Loading

0 comments on commit c619253

Please sign in to comment.