Skip to content

Commit 2e3d47a

Browse files
committed
Run formatter.
1 parent 4061dda commit 2e3d47a

21 files changed

+191
-206
lines changed

src/view/__main__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ def main(ctx: click.Context, debug: bool, version: bool) -> None:
115115

116116

117117
@main.group()
118-
def logs():
119-
...
118+
def logs(): ...
120119

121120

122121
@logs.command()

src/view/_loader.py

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,15 @@
55
import warnings
66
from dataclasses import _MISSING_TYPE, Field, dataclass
77
from pathlib import Path
8-
from typing import (TYPE_CHECKING, ForwardRef, Iterable, NamedTuple, TypedDict,
9-
get_args, get_type_hints)
8+
from typing import (
9+
TYPE_CHECKING,
10+
ForwardRef,
11+
Iterable,
12+
NamedTuple,
13+
TypedDict,
14+
get_args,
15+
get_type_hints,
16+
)
1017

1118
from _view import Context
1219

@@ -25,11 +32,15 @@ def _eval_type(*args) -> Any: ...
2532

2633
from ._logging import Internal
2734
from ._util import docs_hint, is_annotated, is_union, set_load
28-
from .exceptions import (DuplicateRouteError, InvalidBodyError,
29-
InvalidRouteError, LoaderWarning,
30-
UnknownBuildStepError, ViewInternalError)
31-
from .routing import (BodyParam, Method, Route, RouteData, RouteInput,
32-
_NoDefault)
35+
from .exceptions import (
36+
DuplicateRouteError,
37+
InvalidBodyError,
38+
InvalidRouteError,
39+
LoaderWarning,
40+
UnknownBuildStepError,
41+
ViewInternalError,
42+
)
43+
from .routing import BodyParam, Method, Route, RouteData, RouteInput, _NoDefault
3344
from .typing import Any, RouteInputDict, TypeInfo, ValueType
3445

3546
ExtNotRequired: Any = None
@@ -348,9 +359,7 @@ def __view_construct__(**kwargs):
348359
vbody_types = vbody
349360

350361
doc = {}
351-
codes.append(
352-
(TYPECODE_CLASS, tp, _format_body(vbody_types, doc, tp))
353-
)
362+
codes.append((TYPECODE_CLASS, tp, _format_body(vbody_types, doc, tp)))
354363
setattr(tp, "_view_doc", doc)
355364
continue
356365

@@ -364,9 +373,7 @@ def __view_construct__(**kwargs):
364373
key, value = get_args(tp)
365374

366375
if key is not str:
367-
raise InvalidBodyError(
368-
f"dictionary keys must be strings, not {key}"
369-
)
376+
raise InvalidBodyError(f"dictionary keys must be strings, not {key}")
370377

371378
tp_codes = _build_type_codes((value,))
372379
codes.append((TYPECODE_DICT, None, tp_codes))
@@ -437,9 +444,7 @@ def finalize(routes: Iterable[Route], app: ViewApp):
437444

438445
for step in route.steps or []:
439446
if step not in app.config.build.steps:
440-
raise UnknownBuildStepError(
441-
f"build step {step!r} is not defined"
442-
)
447+
raise UnknownBuildStepError(f"build step {step!r} is not defined")
443448

444449
if route.method:
445450
target = targets[route.method]
@@ -487,9 +492,7 @@ def finalize(routes: Iterable[Route], app: ViewApp):
487492
route.inputs.insert(index, 1)
488493
continue
489494

490-
default = (
491-
v.default if v.default is not inspect._empty else _NoDefault
492-
)
495+
default = v.default if v.default is not inspect._empty else _NoDefault
493496

494497
route.inputs.insert(
495498
index,
@@ -584,9 +587,7 @@ def load_fs(app: ViewApp, target_dir: Path) -> None:
584587
)
585588
else:
586589
path_obj = Path(path)
587-
stripped = list(
588-
path_obj.parts[len(target_dir.parts) :]
589-
) # noqa
590+
stripped = list(path_obj.parts[len(target_dir.parts) :]) # noqa
590591
if stripped[-1] == "index.py":
591592
stripped.pop(len(stripped) - 1)
592593

src/view/app.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
Note that the actual ASGI functionality is stored under the `ViewApp`
77
extension type, which `App` inherits from.
88
"""
9+
910
from __future__ import annotations
1011

1112
import asyncio
@@ -1006,15 +1007,13 @@ async def markdown(
10061007
def context(
10071008
self,
10081009
r_or_none: RouteOrCallable[P],
1009-
) -> Route[P]:
1010-
...
1010+
) -> Route[P]: ...
10111011

10121012
@overload
10131013
def context(
10141014
self,
10151015
r_or_none: None = None,
1016-
) -> Callable[[RouteOrCallable[P]], Route[P]]:
1017-
...
1016+
) -> Callable[[RouteOrCallable[P]], Route[P]]: ...
10181017

10191018
def context(
10201019
self,
@@ -1149,8 +1148,10 @@ async def _spawn(self, coro: Coroutine[Any, Any, Any]):
11491148
welcome()
11501149

11511150
if self.config.dev:
1152-
Service.warning("Development mode is enabled, do not expect high performance.")
1153-
1151+
Service.warning(
1152+
"Development mode is enabled, do not expect high performance."
1153+
)
1154+
11541155
async def subcoro():
11551156
Service.info(
11561157
f"Server running at http://{self.config.server.host}:{self.config.server.port} with backend [bold green]{self.config.server.backend}[/]" # noqa
@@ -1403,12 +1404,10 @@ async def test(self):
14031404
await ctx.stop()
14041405

14051406
@overload
1406-
def docs(self, file: None = None) -> str:
1407-
...
1407+
def docs(self, file: None = None) -> str: ...
14081408

14091409
@overload
1410-
def docs(self, file: TextIO) -> None:
1411-
...
1410+
def docs(self, file: TextIO) -> None: ...
14121411

14131412
@overload
14141413
def docs(
@@ -1417,8 +1416,7 @@ def docs(
14171416
*,
14181417
encoding: str = "utf-8",
14191418
overwrite: bool = True,
1420-
) -> None:
1421-
...
1419+
) -> None: ...
14221420

14231421
@overload
14241422
def docs(
@@ -1427,8 +1425,7 @@ def docs(
14271425
*,
14281426
encoding: str = "utf-8",
14291427
overwrite: bool = True,
1430-
) -> None:
1431-
...
1428+
) -> None: ...
14321429

14331430
def docs(
14341431
self,

src/view/build.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
While this module is considered public, you likely don't need the functions in here.
55
Instead, you should just let view.py do most of the work, such as through calling `build_app` upon startup.
66
"""
7+
78
from __future__ import annotations
89

910
import asyncio

src/view/config.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class AppConfig(BaseSettings):
3939
uvloop: Union[Literal["decide"], bool] = "decide"
4040
loader_path: Path = Path("./routes")
4141

42+
4243
class ServerConfig(BaseSettings):
4344
host: IPv4Address = IPv4Address("0.0.0.0")
4445
port: int = 5000
@@ -111,9 +112,7 @@ class BuildStep(BaseSettings):
111112
class BuildConfig(BaseSettings):
112113
path: Path = Path("./build")
113114
default_steps: Union[List[str], None] = None
114-
steps: Dict[str, Union[BuildStep, List[BuildStep]]] = Field(
115-
default_factory=dict
116-
)
115+
steps: Dict[str, Union[BuildStep, List[BuildStep]]] = Field(default_factory=dict)
117116
parallel: bool = False
118117

119118

src/view/databases.py

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,19 @@
3939

4040
class _Connection(ABC):
4141
@abstractmethod
42-
async def connect(self) -> None:
43-
...
42+
async def connect(self) -> None: ...
4443

4544
@abstractmethod
46-
async def close(self) -> None:
47-
...
45+
async def close(self) -> None: ...
4846

4947
@abstractmethod
50-
async def insert(self, table: str, json: dict) -> None:
51-
...
48+
async def insert(self, table: str, json: dict) -> None: ...
5249

5350
@abstractmethod
54-
async def find(self, table: str, json: dict) -> None:
55-
...
51+
async def find(self, table: str, json: dict) -> None: ...
5652

5753
@abstractmethod
58-
async def migrate(self, table: str, vbody: dict) -> None:
59-
...
54+
async def migrate(self, table: str, vbody: dict) -> None: ...
6055

6156

6257
_SQL_TYPES: dict[type, str] = {
@@ -165,11 +160,9 @@ async def close(self) -> None:
165160
self.connection = None
166161
self.cursor = None
167162

168-
async def insert(self, table: str, json: dict) -> None:
169-
...
163+
async def insert(self, table: str, json: dict) -> None: ...
170164

171-
async def find(self, table: str, json: dict) -> None:
172-
...
165+
async def find(self, table: str, json: dict) -> None: ...
173166

174167
async def migrate(self, table: str, vbody: dict):
175168
assert self.cursor is not None
@@ -307,30 +300,24 @@ def __repr__(self) -> str:
307300
__str__ = __repr__
308301

309302
@classmethod
310-
def find(cls) -> list[Self]:
311-
...
303+
def find(cls) -> list[Self]: ...
312304

313305
@classmethod
314-
def unique(cls) -> Self:
315-
...
306+
def unique(cls) -> Self: ...
316307

317-
def exists(self) -> bool:
318-
...
308+
def exists(self) -> bool: ...
319309

320310
def save(self) -> None:
321311
conn = self._assert_conn()
322312

323313
conn.insert(self.__view_table__, self._json())
324314

325-
def _json(self) -> dict[str, Any]:
326-
...
315+
def _json(self) -> dict[str, Any]: ...
327316

328-
def json(self) -> dict[str, Any]:
329-
...
317+
def json(self) -> dict[str, Any]: ...
330318

331319
@classmethod
332-
def from_json(cls, json: dict[str, Any]) -> Self:
333-
...
320+
def from_json(cls, json: dict[str, Any]) -> Self: ...
334321

335322
@classmethod
336323
def _assert_conn(cls) -> _Connection:

src/view/exceptions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
44
Everything in this module inherits from `ViewError` or `ViewWarning`.
55
"""
6+
67
from __future__ import annotations
78

89
from rich.console import RenderableType

src/view/patterns.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
44
This contains the `path()` function, which acts as the logic for the Django-like `patterns` loader.
55
"""
6+
67
from __future__ import annotations
78

89
from ._util import run_path

src/view/response.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
This module contains the `Response` class, which is conventionally used as the base response in view.py
55
All other classes that inherit from it are contained in this module.
66
"""
7+
78
from __future__ import annotations
89

910
import secrets
@@ -18,8 +19,13 @@
1819
from typing_extensions import final
1920

2021
from .exceptions import InvalidResultError
21-
from .typing import (BodyTranslateStrategy, MaybeAwaitable, SameSite,
22-
SupportsViewResult, ViewResult)
22+
from .typing import (
23+
BodyTranslateStrategy,
24+
MaybeAwaitable,
25+
SameSite,
26+
SupportsViewResult,
27+
ViewResult,
28+
)
2329
from .util import call_result, timestamp
2430

2531
if TYPE_CHECKING:
@@ -227,7 +233,11 @@ def __init__(
227233
headers: dict[str, str] | None = None,
228234
) -> None:
229235
super().__init__(
230-
body, status, headers, body_translate="custom", content_type="text/html",
236+
body,
237+
status,
238+
headers,
239+
body_translate="custom",
240+
content_type="text/html",
231241
)
232242

233243
def translate_body(self, body: HTMLContent) -> str:

0 commit comments

Comments
 (0)