Skip to content

Commit

Permalink
formatting: use 99 as max line length for black
Browse files Browse the repository at this point in the history
  • Loading branch information
sumnerevans committed Dec 28, 2021
1 parent 9249cde commit 8870e72
Show file tree
Hide file tree
Showing 15 changed files with 76 additions and 202 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ indent_style = space
indent_size = 4

[*.py]
max_line_length = 88
max_line_length = 99

# Indentation override for all JSON/YAML files
[*.{json,yaml,yml}]
Expand Down
8 changes: 2 additions & 6 deletions linkedin_matrix/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ async def resend_bridge_info(self):
async def get_portal(self, room_id: RoomID) -> Portal:
return await Portal.get_by_mxid(room_id)

async def get_puppet(
self, user_id: UserID, create: bool = False
) -> Optional[Puppet]:
async def get_puppet(self, user_id: UserID, create: bool = False) -> Optional[Puppet]:
return await Puppet.get_by_mxid(user_id, create=create)

async def get_double_puppet(self, user_id: UserID) -> Puppet:
Expand All @@ -113,9 +111,7 @@ def is_bridge_ghost(self, user_id: UserID) -> bool:
return bool(Puppet.get_id_from_mxid(user_id))

async def count_logged_in_users(self) -> int:
return len(
[user for user in User.by_li_member_urn.values() if user.li_member_urn]
)
return len([user for user in User.by_li_member_urn.values() if user.li_member_urn])

async def manhole_global_namespace(self, user_id: UserID) -> dict[str, Any]:
return {
Expand Down
4 changes: 1 addition & 3 deletions linkedin_matrix/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ def __getitem__(self, key: str) -> Any:
def forbidden_defaults(self) -> list[ForbiddenDefault]:
return [
*super().forbidden_defaults,
ForbiddenDefault(
"appservice.database", "postgres://username:password@hostname/db"
),
ForbiddenDefault("appservice.database", "postgres://username:password@hostname/db"),
ForbiddenDefault("bridge.permissions", ForbiddenKey("example.com")),
]

Expand Down
6 changes: 2 additions & 4 deletions linkedin_matrix/db/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def _from_row(cls, row: Optional[Record]) -> Optional["Message"]:
li_thread_urn=URN(li_thread_urn),
li_sender_urn=URN(li_sender_urn),
li_receiver_urn=URN(li_receiver_urn),
timestamp=datetime.fromtimestamp(timestamp)
timestamp=datetime.fromtimestamp(timestamp),
)

@classmethod
Expand All @@ -72,9 +72,7 @@ async def get_by_li_message_urn(
li_receiver_urn: URN,
index: int = 0,
) -> Optional["Message"]:
query = Message.select_constructor(
"li_message_urn=$1 AND li_receiver_urn=$2 AND index=$3"
)
query = Message.select_constructor("li_message_urn=$1 AND li_receiver_urn=$2 AND index=$3")
row = await cls.db.fetchrow(
query,
li_message_urn.id_str(),
Expand Down
4 changes: 1 addition & 3 deletions linkedin_matrix/db/upgrade/v04_add_portal_meta_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
from . import upgrade_table


@upgrade_table.register(
description="Add name_set, avatar_set, and topic_set to portals"
)
@upgrade_table.register(description="Add name_set, avatar_set, and topic_set to portals")
async def upgrade_v4(conn: Connection):
create_table_queries = [
"ALTER TABLE portal ADD COLUMN name_set BOOLEAN NOT NULL DEFAULT false",
Expand Down
4 changes: 1 addition & 3 deletions linkedin_matrix/db/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ def _from_row(cls, row: Optional[Record]) -> Optional["User"]:
client_pickle = data.pop("client_pickle")
li_member_urn = data.pop("li_member_urn")
return cls(
client=LinkedInMessaging.from_pickle(client_pickle)
if client_pickle
else None,
client=LinkedInMessaging.from_pickle(client_pickle) if client_pickle else None,
li_member_urn=URN(li_member_urn) if li_member_urn else None,
**data,
)
Expand Down
4 changes: 1 addition & 3 deletions linkedin_matrix/db/user_portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ async def get(
portal: str,
portal_receiver: str,
) -> Optional["UserPortal"]:
query = UserPortal.select_constructor(
'"user"=$1 AND portal=$2 AND portal_receiver=$3'
)
query = UserPortal.select_constructor('"user"=$1 AND portal=$2 AND portal_receiver=$3')
row = await cls.db.fetchrow(query, user, portal, portal_receiver)
return cls._from_row(row)

Expand Down
8 changes: 2 additions & 6 deletions linkedin_matrix/get_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,15 @@ def run(cmd: list[str]) -> Any:
git_revision_url = None

try:
git_tag = (
run(["git", "describe", "--exact-match", "--tags"]).strip().decode("ascii")
)
git_tag = run(["git", "describe", "--exact-match", "--tags"]).strip().decode("ascii")
except (subprocess.SubprocessError, OSError):
git_tag = None
else:
git_revision = "unknown"
git_revision_url = None
git_tag = None

git_tag_url = (
f"https://gitlab.com/beeper/linkedin/-/releases/{git_tag}" if git_tag else None
)
git_tag_url = f"https://gitlab.com/beeper/linkedin/-/releases/{git_tag}" if git_tag else None

if git_tag and __version__ == git_tag[1:].replace("-", ""):
version = __version__
Expand Down
15 changes: 4 additions & 11 deletions linkedin_matrix/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@

class MatrixHandler(BaseMatrixHandler):
def __init__(self, bridge: "LinkedInBridge"):
prefix, suffix = (
bridge.config["bridge.username_template"].format(userid=":").split(":")
)
prefix, suffix = bridge.config["bridge.username_template"].format(userid=":").split(":")
homeserver = bridge.config["homeserver.domain"]
self.user_id_prefix = f"@{prefix}"
self.user_id_suffix = f"{suffix}:{homeserver}"
Expand All @@ -39,8 +37,7 @@ async def send_welcome_message(self, room_id: RoomID, inviter: "u.User"):
await inviter.save()
await self.az.intent.send_notice(
room_id,
"This room has been marked as your LinkedIn Messages bridge notice "
"room.",
"This room has been marked as your LinkedIn Messages bridge notice room.",
)

async def handle_read_receipt(self, user: "u.User", portal: "po.Portal", *_):
Expand Down Expand Up @@ -132,10 +129,6 @@ async def handle_ephemeral_event(

async def handle_event(self, evt: Event):
if evt.type == EventType.ROOM_REDACTION:
await self.handle_redaction(
evt.room_id, evt.sender, evt.redacts, evt.event_id
)
await self.handle_redaction(evt.room_id, evt.sender, evt.redacts, evt.event_id)
elif evt.type == EventType.REACTION:
await self.handle_reaction(
evt.room_id, evt.sender, evt.event_id, evt.content
)
await self.handle_reaction(evt.room_id, evt.sender, evt.event_id, evt.content)
Loading

0 comments on commit 8870e72

Please sign in to comment.