Skip to content

Commit 8a7a19e

Browse files
committed
run formatter again
1 parent 9fce819 commit 8a7a19e

File tree

18 files changed

+160
-188
lines changed

18 files changed

+160
-188
lines changed

src/view/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
from . import _codec
1717
from .__about__ import *
1818
from .app import *
19+
from .build import *
1920
from .components import *
2021
from .default_page import *
21-
from .build import *
2222
from .exceptions import *
2323
from .logging import *
2424
from .patterns import *

src/view/_loader.py

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

1811
from _view import Context
1912

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

3326
from ._logging import Internal
3427
from ._util import docs_hint, is_annotated, is_union, set_load
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
28+
from .exceptions import (DuplicateRouteError, InvalidBodyError,
29+
InvalidRouteError, LoaderWarning,
30+
UnknownBuildStepError, ViewInternalError)
31+
from .routing import (BodyParam, Method, Route, RouteData, RouteInput,
32+
_NoDefault)
4433
from .typing import Any, RouteInputDict, TypeInfo, ValueType
4534

4635
ExtNotRequired: Any = None

src/view/_logging.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
from rich.live import Live
2020
from rich.logging import RichHandler
2121
from rich.panel import Panel
22-
from rich.progress import BarColumn, Progress, Task, TaskProgressColumn, TextColumn
22+
from rich.progress import (BarColumn, Progress, Task, TaskProgressColumn,
23+
TextColumn)
2324
from rich.progress_bar import ProgressBar
2425
from rich.table import Table
2526
from rich.text import Text

src/view/_util.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
import weakref
1212
from collections.abc import Iterable
1313
from pathlib import Path
14+
from types import CodeType as Code
1415
from types import FrameType as Frame
15-
from types import FunctionType as Function, CodeType as Code
16+
from types import FunctionType as Function
1617
from typing import Any, NoReturn, Union
1718

1819
from rich.markup import escape

src/view/app.py

Lines changed: 46 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,8 @@
1919
from threading import Thread
2020
from types import FrameType as Frame
2121
from types import TracebackType as Traceback
22-
from typing import (
23-
Any,
24-
AsyncIterator,
25-
Callable,
26-
Coroutine,
27-
Generic,
28-
Iterable,
29-
TextIO,
30-
TypeVar,
31-
get_type_hints,
32-
overload,
33-
)
22+
from typing import (Any, AsyncIterator, Callable, Coroutine, Generic, Iterable,
23+
TextIO, TypeVar, get_type_hints, overload)
3424
from urllib.parse import urlencode
3525

3626
import ujson
@@ -43,36 +33,19 @@
4333
from .__main__ import welcome
4434
from ._docs import markdown_docs
4535
from ._loader import finalize, load_fs, load_patterns, load_simple
46-
from ._logging import (
47-
LOGS,
48-
Internal,
49-
Service,
50-
enter_server,
51-
exit_server,
52-
format_warnings,
53-
)
36+
from ._logging import (LOGS, Internal, Service, enter_server, exit_server,
37+
format_warnings)
5438
from ._parsers import supply_parsers
5539
from ._util import make_hint, needs_dep
5640
from .build import build_app, build_steps
5741
from .config import Config, load_config
58-
from .exceptions import (
59-
BadEnvironmentError,
60-
InvalidCustomLoaderError,
61-
ViewError,
62-
ViewInternalError,
63-
)
42+
from .exceptions import (BadEnvironmentError, InvalidCustomLoaderError,
43+
ViewError, ViewInternalError)
6444
from .logging import _LogArgs, log
6545
from .response import HTML
6646
from .routing import Path as _RouteDeco
67-
from .routing import (
68-
Route,
69-
RouteInput,
70-
RouteOrCallable,
71-
RouteOrWebsocket,
72-
V,
73-
_NoDefault,
74-
_NoDefaultType,
75-
)
47+
from .routing import (Route, RouteInput, RouteOrCallable, RouteOrWebsocket, V,
48+
_NoDefault, _NoDefaultType)
7649
from .routing import body as body_impl
7750
from .routing import context as context_impl
7851
from .routing import delete, get, options, patch, post, put
@@ -92,7 +65,9 @@
9265
T = TypeVar("T")
9366
P = ParamSpec("P")
9467

95-
_ROUTES_WARN_MSG = "routes argument should only be passed when load strategy is manual"
68+
_ROUTES_WARN_MSG = (
69+
"routes argument should only be passed when load strategy is manual"
70+
)
9671
_ConfigSpecified = None
9772

9873
B = TypeVar("B", bound=BaseException)
@@ -202,7 +177,9 @@ async def _server_send(self, data: dict):
202177
self.send_queue.put_nowait(data)
203178

204179
async def send(self, message: str) -> None:
205-
self.recv_queue.put_nowait({"type": "websocket.receive", "text": message})
180+
self.recv_queue.put_nowait(
181+
{"type": "websocket.receive", "text": message}
182+
)
206183

207184
async def receive(self) -> str:
208185
data = await _to_thread(self.send_queue.get)
@@ -217,7 +194,9 @@ async def receive(self) -> str:
217194
return msg
218195

219196
async def handshake(self) -> None:
220-
assert (await _to_thread(self.send_queue.get))["type"] == "websocket.accept"
197+
assert (await _to_thread(self.send_queue.get))[
198+
"type"
199+
] == "websocket.accept"
221200

222201

223202
class TestingContext:
@@ -241,9 +220,12 @@ async def send(_: dict[str, Any]):
241220
async def stop(self) -> None:
242221
await self._lifespan.put("lifespan.shutdown")
243222

244-
def _gen_headers(self, headers: dict[str, str]) -> list[tuple[bytes, bytes]]:
223+
def _gen_headers(
224+
self, headers: dict[str, str]
225+
) -> list[tuple[bytes, bytes]]:
245226
return [
246-
(key.encode(), value.encode()) for key, value in (headers or {}).items()
227+
(key.encode(), value.encode())
228+
for key, value in (headers or {}).items()
247229
]
248230

249231
def _truncate(self, route: str) -> str:
@@ -477,7 +459,9 @@ def __init__(self, status: int = 400, message: str | None = None) -> None:
477459
message: The (optional) message to send back to the client. If none, uses the default error message (e.g. `Bad Request` for status `400`).
478460
"""
479461
if status not in ERROR_CODES:
480-
raise InvalidStatusError("status code can only be a client or server error")
462+
raise InvalidStatusError(
463+
"status code can only be a client or server error"
464+
)
481465

482466
self.status = status
483467
self.message = message
@@ -541,7 +525,9 @@ def _hook(tp: type[B], value: B, traceback: Traceback) -> None:
541525
print(value.hint)
542526

543527
if isinstance(value, ViewInternalError):
544-
print("[bold dim red]This is an internal error, not your fault![/]")
528+
print(
529+
"[bold dim red]This is an internal error, not your fault![/]"
530+
)
545531
print(
546532
"[bold dim red]Please report this at https://github.com/ZeroIntensity/view.py/issues[/]"
547533
)
@@ -564,7 +550,9 @@ def _finalize(self) -> None:
564550
if self.loaded:
565551
return
566552

567-
warnings.warn("load() was never called (did you forget to start the app?)")
553+
warnings.warn(
554+
"load() was never called (did you forget to start the app?)"
555+
)
568556
split = self.config.app.app_path.split(":", maxsplit=1)
569557

570558
if len(split) != 2:
@@ -696,7 +684,9 @@ async def index():
696684
app.run()
697685
```
698686
"""
699-
return self._method_wrapper(path, doc, cache_rate, get, steps, parallel_build)
687+
return self._method_wrapper(
688+
path, doc, cache_rate, get, steps, parallel_build
689+
)
700690

701691
def post(
702692
self,
@@ -841,7 +831,9 @@ async def index():
841831
app.run()
842832
```
843833
"""
844-
return self._method_wrapper(path, doc, cache_rate, put, steps, parallel_build)
834+
return self._method_wrapper(
835+
path, doc, cache_rate, put, steps, parallel_build
836+
)
845837

846838
def options(
847839
self,
@@ -930,7 +922,9 @@ def query(
930922
"""
931923

932924
def inner(func: RouteOrCallable[P]) -> Route[P]:
933-
route: Route[P] = query_impl(name, *tps, doc=doc, default=default)(func)
925+
route: Route[P] = query_impl(name, *tps, doc=doc, default=default)(
926+
func
927+
)
934928
self._push_route(route)
935929
return route
936930

@@ -953,7 +947,9 @@ def body(
953947
"""
954948

955949
def inner(func: RouteOrCallable[P]) -> Route[P]:
956-
route: Route[P] = body_impl(name, *tps, doc=doc, default=default)(func)
950+
route: Route[P] = body_impl(name, *tps, doc=doc, default=default)(
951+
func
952+
)
957953
self._push_route(route)
958954
return route
959955

@@ -977,7 +973,9 @@ async def template(
977973
else:
978974
f = frame # type: ignore
979975

980-
return await template(name, directory, engine, f, app=self, **parameters)
976+
return await template(
977+
name, directory, engine, f, app=self, **parameters
978+
)
981979

982980
async def markdown(
983981
self,

src/view/build.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,9 @@
2222
import platform
2323

2424
from .config import BuildStep, Platform
25-
from .exceptions import (
26-
BuildError,
27-
BuildWarning,
28-
MissingRequirementError,
29-
PlatformNotSupportedError,
30-
UnknownBuildStepError,
31-
ViewInternalError,
32-
)
25+
from .exceptions import (BuildError, BuildWarning, MissingRequirementError,
26+
PlatformNotSupportedError, UnknownBuildStepError,
27+
ViewInternalError)
3328
from .response import to_response
3429

3530
__all__ = "build_steps", "build_app"

src/view/databases.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
from abc import ABC, abstractmethod
55
from datetime import datetime
66
from enum import Enum
7-
from typing import Any, ClassVar, Set, TypeVar, Union, get_origin, get_type_hints
7+
from typing import (Any, ClassVar, Set, TypeVar, Union, get_origin,
8+
get_type_hints)
89

910
from typing_extensions import Annotated, Self, dataclass_transform, get_args
1011

@@ -128,7 +129,9 @@ def create_database_connection(self):
128129

129130
async def connect(self) -> None:
130131
try:
131-
self.connection = await asyncio.to_thread(self.create_database_connection)
132+
self.connection = await asyncio.to_thread(
133+
self.create_database_connection
134+
)
132135
self.cursor = await asyncio.to_thread(self.connection.cursor) # type: ignore
133136
except psycopg2.Error as e:
134137
raise ValueError(
@@ -279,11 +282,14 @@ def __init__(self, *args: Any, **kwargs: Any):
279282
setattr(self, k, args[index])
280283

281284
def __init_subclass__(cls, **kwargs: Any):
282-
cls.__view_table__ = kwargs.get("table") or ("vpy_" + cls.__name__.lower())
285+
cls.__view_table__ = kwargs.get("table") or (
286+
"vpy_" + cls.__name__.lower()
287+
)
283288
model_hints = get_type_hints(Model)
284289
actual_hints = get_type_hints(cls)
285290
params = {
286-
k: actual_hints[k] for k in (model_hints.keys() ^ actual_hints.keys())
291+
k: actual_hints[k]
292+
for k in (model_hints.keys() ^ actual_hints.keys())
287293
}
288294

289295
for k, v in params.items():

src/view/patterns.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,8 @@
22

33
from ._util import run_path
44
from .exceptions import DuplicateRouteError, InvalidRouteError
5-
from .routing import (
6-
Callable,
7-
Method,
8-
Route,
9-
RouteOrCallable,
10-
delete,
11-
get,
12-
options,
13-
patch,
14-
post,
15-
put,
16-
)
5+
from .routing import (Callable, Method, Route, RouteOrCallable, delete, get,
6+
options, patch, post, put)
177
from .routing import route as route_impl
188
from .typing import StrMethod, ViewRoute
199

src/view/response.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from .components import DOMNode
1111
from .exceptions import InvalidResultError
12-
from .typing import BodyTranslateStrategy, SameSite, ViewResult, ResponseBody
12+
from .typing import BodyTranslateStrategy, ResponseBody, SameSite, ViewResult
1313
from .util import timestamp
1414

1515
T = TypeVar("T")

src/view/routing.py

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,17 @@
88
from contextlib import suppress
99
from dataclasses import dataclass, field
1010
from enum import Enum
11-
from typing import (
12-
Any,
13-
Callable,
14-
Generic,
15-
Iterable,
16-
Literal,
17-
Type,
18-
TypeVar,
19-
Union,
20-
overload,
21-
)
11+
from typing import (Any, Callable, Generic, Iterable, Literal, Type, TypeVar,
12+
Union, overload)
2213

2314
from typing_extensions import ParamSpec, TypeAlias
2415

2516
from ._logging import Service
2617
from ._util import LoadChecker, make_hint
2718
from .build import run_step
2819
from .exceptions import InvalidRouteError, MistakeError
29-
from .typing import (
30-
TYPE_CHECKING,
31-
Middleware,
32-
StrMethod,
33-
Validator,
34-
ValueType,
35-
ViewResult,
36-
ViewRoute,
37-
WebSocketRoute,
38-
)
20+
from .typing import (TYPE_CHECKING, Middleware, StrMethod, Validator,
21+
ValueType, ViewResult, ViewRoute, WebSocketRoute)
3922

4023
if TYPE_CHECKING:
4124
from .app import App

0 commit comments

Comments
 (0)