Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove redundant type hints from docstrings. #367

Merged
merged 14 commits into from
Jun 24, 2021
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/366.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Revome redunant type hints from docstrings.
H-Shay marked this conversation as resolved.
Show resolved Hide resolved
10 changes: 0 additions & 10 deletions sydent/db/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@ def getAccountByToken(self, token: str) -> Optional[Account]:
Select the account matching the given token, if any.

:param token: The token to identify the account, if any.
:type token: unicode

:return: The account matching the token, or None if no account matched.
:rtype: Account or None
"""
cur = self.sydent.db.cursor()
res = cur.execute(
Expand All @@ -54,12 +52,9 @@ def storeAccount(
Stores an account for the given user ID.

:param user_id: The Matrix user ID to create an account for.
:type user_id: unicode
:param creation_ts: The timestamp in milliseconds.
:type creation_ts: int
:param consent_version: The version of the terms of services that the user last
accepted.
:type consent_version: str or None
"""
cur = self.sydent.db.cursor()
cur.execute(
Expand All @@ -75,9 +70,7 @@ def setConsentVersion(self, user_id: str, consent_version: Optional[str]) -> Non
given version.

:param user_id: The Matrix ID of the user that has agreed to the terms.
:type user_id: str
:param consent_version: The version of the document the user has agreed to.
:type consent_version: unicode or None
"""
cur = self.sydent.db.cursor()
cur.execute(
Expand All @@ -91,9 +84,7 @@ def addToken(self, user_id: str, token: str) -> None:
Stores the authentication token for a given user.

:param user_id: The Matrix user ID to save the given token for.
:type user_id: unicode
:param token: The token to store for that user ID.
:type token: unicode
"""
cur = self.sydent.db.cursor()
cur.execute(
Expand All @@ -107,7 +98,6 @@ def delToken(self, token: str) -> int:
Deletes an authentication token from the database.

:param token: The token to delete from the database.
:type token: unicode
"""
cur = self.sydent.db.cursor()
cur.execute(
Expand Down
3 changes: 0 additions & 3 deletions sydent/db/hashing_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def get_lookup_pepper(self) -> Optional[str]:

:return: A pepper if it exists in the database, or None if one does
not exist
:rtype: unicode or None
"""
cur = self.sydent.db.cursor()
res = cur.execute("select lookup_pepper from hashing_metadata")
Expand All @@ -53,10 +52,8 @@ def store_lookup_pepper(
"""Stores a new lookup pepper in the hashing_metadata db table and rehashes all 3PIDs

:param hashing_function: A function with single input and output strings
:type hashing_function func(str) -> str

:param pepper: The pepper to store in the database
:type pepper: str
"""
cur = self.sydent.db.cursor()

Expand Down
17 changes: 0 additions & 17 deletions sydent/db/invite_tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,10 @@ def storeToken(
Store a new invite token and its metadata.

:param medium: The medium of the 3PID the token is associated to.
:type medium: unicode
:param address: The address of the 3PID the token is associated to.
:type address: unicode
:param roomId: The ID of the room the 3PID is invited in.
:type roomId: unicode
:param sender: The MXID of the user that sent the invite.
:type sender: unicode
:param token: The token to store.
:type token: unicode
"""
cur = self.sydent.db.cursor()

Expand All @@ -57,13 +52,10 @@ def getTokens(
yet.

:param medium: The medium of the 3PID to get tokens for.
:type medium: unicode
:param address: The address of the 3PID to get tokens for.
:type address: unicode

:return: A list of dicts, each containing a pending token and its metadata for
this 3PID.
:rtype: list[dict[str, unicode or dict[str, unicode]]
"""
cur = self.sydent.db.cursor()

Expand Down Expand Up @@ -112,9 +104,7 @@ def markTokensAsSent(self, medium: str, address: str) -> None:
delivered to a homeserver so they're not delivered again in the future.

:param medium: The medium of the 3PID to update tokens for.
:type medium: unicode
:param address: The address of the 3PID to update tokens for.
:type address: unicode
"""
cur = self.sydent.db.cursor()

Expand All @@ -133,7 +123,6 @@ def storeEphemeralPublicKey(self, publicKey: str) -> None:
Saves the provided ephemeral public key.

:param publicKey: The key to store.
:type publicKey: unicode
"""
cur = self.sydent.db.cursor()
cur.execute(
Expand All @@ -150,10 +139,8 @@ def validateEphemeralPublicKey(self, publicKey: str) -> bool:
verification count.

:param publicKey: The public key to validate.
:type publicKey: unicode

:return: Whether the key is valid.
:rtype: bool
"""
cur = self.sydent.db.cursor()
cur.execute(
Expand All @@ -170,11 +157,9 @@ def getSenderForToken(self, token: str) -> Optional[str]:
Retrieves the MXID of the user that sent the invite the provided token is for.

:param token: The token to retrieve the sender of.
:type token: unicode

:return: The invite's sender, or None if the token doesn't match an existing
invite.
:rtype: unicode or None
"""
cur = self.sydent.db.cursor()
res = cur.execute("SELECT sender FROM invite_tokens WHERE token = ?", (token,))
Expand All @@ -188,9 +173,7 @@ def deleteTokens(self, medium: str, address: str) -> None:
Deletes every token for a given 3PID.

:param medium: The medium of the 3PID to delete tokens for.
:type medium: unicode
:param address: The address of the 3PID to delete tokens for.
:type address: unicode
"""
cur = self.sydent.db.cursor()

Expand Down
6 changes: 0 additions & 6 deletions sydent/db/peers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@ def getPeerByName(self, name: str) -> Optional[RemotePeer]:
Retrieves a remote peer using it's server name.

:param name: The server name of the peer.
:type name: unicode

:return: The retrieved peer.
:rtype: RemotePeer
"""
cur = self.sydent.db.cursor()
res = cur.execute(
Expand Down Expand Up @@ -64,7 +62,6 @@ def getAllPeers(self) -> List[RemotePeer]:
Retrieve all of the remote peers from the database.

:return: A list of the remote peers this server knows about.
:rtype: list[RemotePeer]
"""
cur = self.sydent.db.cursor()
res = cur.execute(
Expand Down Expand Up @@ -104,12 +101,9 @@ def setLastSentVersionAndPokeSucceeded(
last successful request sent to that peer.

:param peerName: The server name of the peer.
:type peerName: unicode
:param lastSentVersion: The ID of the last association sent to that peer.
:type lastSentVersion: int
:param lastPokeSucceeded: The timestamp in milliseconds of the last successful
request sent to that peer.
:type lastPokeSucceeded: int
"""
cur = self.sydent.db.cursor()
cur.execute(
Expand Down
4 changes: 0 additions & 4 deletions sydent/db/terms.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@ def getAgreedUrls(self, user_id: str) -> List[str]:
Retrieves the URLs of the terms the given user has agreed to.

:param user_id: Matrix user ID to fetch the URLs for.
:type user_id: str

:return: A list of the URLs of the terms accepted by the user.
:rtype: list[unicode]
"""
cur = self.sydent.db.cursor()
res = cur.execute(
Expand All @@ -53,9 +51,7 @@ def addAgreedUrls(self, user_id: str, urls: List[str]) -> None:
Saves that the given user has accepted the terms at the given URLs.

:param user_id: The Matrix user ID that has accepted the terms.
:type user_id: str
:param urls: The list of URLs.
:type urls: list[unicode]
"""
cur = self.sydent.db.cursor()
cur.executemany(
Expand Down
28 changes: 0 additions & 28 deletions sydent/db/threepid_associations.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def addOrUpdateAssociation(self, assoc: ThreepidAssociation) -> None:
Updates an association, or creates one if none exists with these parameters.

:param assoc: The association to create or update.
:type assoc: ThreepidAssociation
"""
cur = self.sydent.db.cursor()

Expand Down Expand Up @@ -63,14 +62,11 @@ def getAssociationsAfterId(
Retrieves every association after the given ID.

:param afterId: The ID after which to retrieve associations.
:type afterId: int
:param limit: The maximum number of associations to retrieve, or None if no
limit.
:type limit: int or None

:return: The retrieved associations (in a dict[id, assoc]), and the highest ID
retrieved (or None if no ID thus no association was retrieved).
:rtype: tuple[dict[int, ThreepidAssociation] or int or None]
"""
cur = self.sydent.db.cursor()

Expand Down Expand Up @@ -107,16 +103,13 @@ def getSignedAssociationsAfterId(
"""Get associations after a given ID, and sign them before returning

:param afterId: The ID to return results after (not inclusive)
:type afterId: int

:param limit: The maximum amount of signed associations to return. None for no
limit.
:type limit: int|None

:return: A tuple consisting of a dictionary containing the signed associations
(id: assoc dict) and an int representing the maximum ID (which is None if
there was no association to retrieve).
:rtype: tuple[dict[int, dict[str, any]] or int or None]
"""
assocs = {}

Expand All @@ -136,9 +129,7 @@ def removeAssociation(self, threepid: Dict[str, str], mxid: str) -> None:
association doesn't exist, log and do nothing.

:param threepid: The 3PID of the binding to remove.
:type threepid: dict[unicode, unicode]
:param mxid: The MXID of the binding to remove.
:type mxid: unicode
"""

cur = self.sydent.db.cursor()
Expand Down Expand Up @@ -193,13 +184,10 @@ def signedAssociationStringForThreepid(
if one exists.

:param medium: The medium of the 3PID.
:type medium: unicode
:param address: The address of the 3PID.
:type address: unicode

:return: The signed association, or None if no association was found for this
3PID.
:rtype: unicode or None
"""
cur = self.sydent.db.cursor()
# We treat address as case-insensitive because that's true for all the
Expand Down Expand Up @@ -227,12 +215,9 @@ def getMxid(self, medium: str, address: str) -> Optional[str]:
Retrieves the MXID associated with a 3PID.

:param medium: The medium of the 3PID.
:type medium: unicode
:param address: The address of the 3PID.
:type address: unicode

:return: The associated MXID, or None if no MXID is associated with this 3PID.
:rtype: unicode or None
"""
cur = self.sydent.db.cursor()
res = cur.execute(
Expand All @@ -257,10 +242,8 @@ def getMxids(
database for. Output is ordered by medium, address, timestamp DESC

:param threepid_tuples: List containing (medium, address) tuples
:type threepid_tuples: list[tuple[unicode]]

:return: a list of (medium, address, mxid) tuples
:rtype: list[tuple[unicode]]
"""
cur = self.sydent.db.cursor()

Expand Down Expand Up @@ -317,17 +300,12 @@ def addAssociation(
Saves an association received through either a replication push or a local push.

:param assoc: The association to add as a high level object.
:type assoc: sydent.threepid.ThreepidAssociation
:param rawSgAssoc: The original raw bytes of the signed association.
:type rawSgAssoc: dict[str, any]
:param originServer: The name of the server the association was created on.
:type originServer: str
:param originId: The ID of the association on the server the association was
created on.
:type originId: int
:param commit: Whether to commit the database transaction after inserting the
association.
:type commit: bool
"""
cur = self.sydent.db.cursor()
cur.execute(
Expand Down Expand Up @@ -355,11 +333,9 @@ def lastIdFromServer(self, server: str) -> Optional[int]:
Retrieves the ID of the last association received from the given peer.

:param server:
:type server: str

:return: The the ID of the last association received from the peer, or None if
no association has ever been received from that peer.
:rtype: int or None
"""
cur = self.sydent.db.cursor()
res = cur.execute(
Expand All @@ -379,9 +355,7 @@ def removeAssociation(self, medium: str, address: str) -> None:
Removes any association stored for the provided 3PID.

:param medium: The medium for the 3PID.
:type medium: unicode
:param address: The address for the 3PID.
:type address: unicode
"""
cur = self.sydent.db.cursor()
cur.execute(
Expand All @@ -401,10 +375,8 @@ def retrieveMxidsForHashes(self, addresses: List[str]) -> Dict[str, str]:
"""Returns a mapping from hash: mxid from a list of given lookup_hash values

:param addresses: An array of lookup_hash values to check against the db
:type addresses: list[unicode]

:returns a dictionary of lookup_hash values to mxids of all discovered matches
:rtype: dict[unicode, unicode]
"""
cur = self.sydent.db.cursor()

Expand Down
Loading