Skip to content

Commit f34c126

Browse files
committed
Refine isort config for the workspace
Root config: list workspace packages explicitly under known_palace (['palace.opds', 'palace.util']) instead of the broad 'palace' prefix. The broad prefix accidentally caught 'from palace import manager' (the module being imported is 'palace', not 'palace.manager') and pulled it into the PALACE section instead of FIRSTPARTY. Add a per-package isort config to packages/palace-util so files there treat palace.util as their FIRSTPARTY (and need no PALACE section since palace-util depends on no other Palace package). isort discovers the nearest pyproject.toml per-file, so editor and pre-commit invocations pick the right config automatically.
1 parent 3da1c0d commit f34c126

6 files changed

Lines changed: 10 additions & 5 deletions

File tree

packages/palace-util/pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,9 @@ Repository = "https://github.com/ThePalaceProject/circulation"
2020

2121
[tool.hatch.build.targets.wheel]
2222
packages = ["src/palace"]
23+
24+
[tool.isort]
25+
combine_as_imports = true
26+
known_first_party = ["palace.util"]
27+
profile = "black"
28+
sections = "FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER"

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ packages = ["src/palace"]
162162
[tool.isort]
163163
combine_as_imports = true
164164
known_first_party = ["palace.manager"]
165-
known_palace = ["palace"]
165+
known_palace = ["palace.opds", "palace.util"]
166166
known_third_party = ["alembic"]
167167
profile = "black"
168168
sections = "FUTURE,STDLIB,THIRDPARTY,PALACE,FIRSTPARTY,LOCALFOLDER"

src/palace/manager/core/app_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
from psycopg2 import OperationalError
1414
from werkzeug.exceptions import HTTPException
1515

16-
from palace import manager
1716
from palace.util.log import LoggerMixin
1817

18+
from palace import manager
1919
from palace.manager.api.admin.config import Configuration as AdminUiConfig
2020
from palace.manager.api.problem_details import FILTERED_BY_LIBRARY_POLICY
2121
from palace.manager.api.util.flask import PalaceFlask, get_request_library

src/palace/manager/util/http/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
import httpx
99
import requests
1010

11-
from palace import manager
1211
from palace.util.datetime_helpers import utc_now
1312

13+
from palace import manager
1414
from palace.manager.util.http.exception import BadResponseException
1515

1616
# In case an app version is not present, we can use this version as a fallback

tests/manager/api/util/test_xray.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import pytest
44

55
from palace import manager
6-
76
from palace.manager.api.util.xray import PalaceXrayMiddleware
87

98

tests/manager/core/test_app_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
from psycopg2 import OperationalError
1313
from pytest import LogCaptureFixture
1414

15-
from palace import manager
1615
from palace.util.log import LogLevel
1716

17+
from palace import manager
1818
from palace.manager.api.admin.config import Configuration as AdminUiConfig
1919
from palace.manager.api.util.flask import PalaceFlask
2020
from palace.manager.core.app_server import (

0 commit comments

Comments
 (0)