Skip to content

Commit

Permalink
Update Black to 2024 style and Python 3.10 target
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Jan 29, 2024
1 parent 19a4b43 commit 77cbbeb
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: psf/black@stable
with:
src: "./mautrix_telegram"
version: "23.11.0"
version: "24.1.1"
- name: pre-commit
run: |
pip install pre-commit
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
exclude_types: [markdown]
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/psf/black
rev: 23.1.0
rev: 24.1.1
hooks:
- id: black
language_version: python3
files: ^mautrix_telegram/.*\.pyi?$
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
files: ^mautrix_telegram/.*\.pyi?$
2 changes: 1 addition & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pre-commit>=2.10.1,<3
isort>=5.10.1,<6
black>=23,<24
black>=24,<25
6 changes: 3 additions & 3 deletions mautrix_telegram/db/telethon_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,9 @@ async def process_entities(self, tlo) -> None:
await self._locked_process_entities(tlo)

async def _locked_process_entities(self, tlo) -> None:
rows: list[
tuple[str, int, int, str | None, str | None, str | None]
] = self._entities_to_rows(tlo)
rows: list[tuple[str, int, int, str | None, str | None, str | None]] = (
self._entities_to_rows(tlo)
)
if not rows:
return
if self.db.scheme == Scheme.POSTGRES:
Expand Down
8 changes: 5 additions & 3 deletions mautrix_telegram/portal_util/power_levels.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,11 @@ def get_base_power_levels(
levels.users_default = overrides.get("users_default", 0)
levels.events_default = overrides.get(
"events_default",
50
if portal.peer_type == "channel" and not portal.megagroup or dbr.send_messages
else 0,
(
50
if portal.peer_type == "channel" and not portal.megagroup or dbr.send_messages
else 0
),
)
for evt_type, value in overrides.get("events", {}).items():
levels.events[EventType.find(evt_type)] = value
Expand Down
8 changes: 5 additions & 3 deletions mautrix_telegram/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,11 @@ async def _track_connection(self) -> None:
self._track_metric(METRIC_CONNECTED, connected)
if connected:
await self.push_bridge_state(
BridgeStateEvent.BACKFILLING
if self._is_backfilling
else BridgeStateEvent.CONNECTED,
(
BridgeStateEvent.BACKFILLING
if self._is_backfilling
else BridgeStateEvent.CONNECTED
),
info=self._bridge_state_info,
)
else:
Expand Down
14 changes: 8 additions & 6 deletions mautrix_telegram/web/provisioning/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ async def _get_portal_response(self, user_id: UserID, portal: Portal) -> web.Res
"about": portal.about,
"username": portal.username,
"megagroup": portal.megagroup,
"can_unbridge": (await portal.can_user_perform(user, "unbridge"))
if user
else False,
"can_unbridge": (
(await portal.can_user_perform(user, "unbridge")) if user else False
),
}
)

Expand Down Expand Up @@ -188,9 +188,11 @@ async def connect_chat(self, request: web.Request) -> web.Response:
if force in ("delete", "unbridge"):
delete = force == "delete"
await portal.cleanup_portal(
"Portal deleted (moving to another room)"
if delete
else "Room unbridged (portal moving to another room)",
(
"Portal deleted (moving to another room)"
if delete
else "Room unbridged (portal moving to another room)"
),
puppets_only=not delete,
)
else:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ line_length = 99

[tool.black]
line-length = 99
target-version = ["py38"]
target-version = ["py310"]

0 comments on commit 77cbbeb

Please sign in to comment.