Skip to content

Commit 82170e1

Browse files
committed
improve code style
1 parent f9b8c75 commit 82170e1

File tree

13 files changed

+67
-28
lines changed

13 files changed

+67
-28
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
commit f9b8c75cbfa0ed87cfdf5d120a12cddab7694db5
2+
Author: Alexeev Bronislav <[email protected]>
3+
Date: Sat Jun 14 00:24:01 2025 +0700
4+
5+
some changes
6+
17
commit 9c57f2d6177ff658b7838550c052bf28abed7c63
28
Author: Alexeev Bronislav <[email protected]>
39
Date: Sat Jun 14 00:18:47 2025 +0700

pyechonext/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,18 @@ def check_for_update():
4242
message = f"New version of library pyEchoNext available: {latest_version}"
4343

4444
print(
45-
f"[red]{'#' * (len(message) + 4)}\n#[/red][bold yellow] {message} [/bold yellow][red]#\n{'#' * (len(message) + 4)}[/red]\n"
45+
f"[red]{'#' * (len(message) + 4)}\n#[/red][bold yellow]"
46+
f" {message} [/bold yellow][red]#\n{'#' * (len(message) + 4)}[/red]\n"
4647
)
4748
elif sum(latest_digits) < sum(current_digits):
4849
print(
49-
f"[yellow]You use [bold]UNSTABLE[/bold] branch of pyEchoNext. Stable version: {latest_version}, your version: {__version__}[/yellow]\n"
50+
"[yellow]You use [bold]UNSTABLE[/bold] branch of pyEchoNext. Stable"
51+
f" version: {latest_version}, your version: {__version__}[/yellow]\n"
5052
)
5153
except requests.RequestException:
5254
print(
53-
f"[dim]Version updates information not available. Your version: {__version__}[/dim]"
55+
"[dim]Version updates information not available. Your version:"
56+
f" {__version__}[/dim]"
5457
)
5558

5659

pyechonext/apidoc_ui/api_documentation.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,15 @@ def generate_spec(self) -> dict:
4444
for url in self._app.urls:
4545
spec["paths"][url.path] = {
4646
"get": {
47-
"summary": str(
48-
f"{url.controller.__doc__}: {url.controller.get.__doc__}"
49-
if url.summary is None
50-
else url.summary
51-
)
52-
.replace("\n", "<br>")
53-
.strip(),
47+
"summary": (
48+
str(
49+
f"{url.controller.__doc__}: {url.controller.get.__doc__}"
50+
if url.summary is None
51+
else url.summary
52+
)
53+
.replace("\n", "<br>")
54+
.strip()
55+
),
5456
"responses": {
5557
"200": {"description": "Successful response"},
5658
"405": {"description": "Method not allow"},

pyechonext/app.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,14 +305,16 @@ def include_router(self, new_router: Router):
305305
[path for path, _ in included_router.routes.items()]
306306
).intersection(new_router_routes):
307307
raise RoutePathExistsError(
308-
f"Next router paths already exists: {set(included_router.routes).intersection(new_router_routes)}"
308+
"Next router paths already exists:"
309+
f" {set(included_router.routes).intersection(new_router_routes)}"
309310
)
310311

311312
self._included_routers.append(new_router)
312313
return
313314

314315
raise RoutePathExistsError(
315-
f"Next router paths already exists: {set(old_router_routes).intersection(new_router_routes)}"
316+
"Next router paths already exists:"
317+
f" {set(old_router_routes).intersection(new_router_routes)}"
316318
)
317319

318320
def _find_handler(

pyechonext/docsgen/document.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ def get_markdown_page(self) -> List[str]:
141141
page = [f"# {self.title}"]
142142
page.append(f"{self.introduction}\n")
143143
page.append(
144-
f" + *Creation date*: {self.creation_date}\n + *Modification date*: {self.modification_date}\n"
144+
f" + *Creation date*: {self.creation_date}\n + *Modification date*:"
145+
f" {self.modification_date}\n"
145146
)
146147

147148
for key, value in self.content.items():

pyechonext/docsgen/projgen.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,14 @@ def _generate_subsections(self, section: DocumentSection):
8383
RoutesSubsection(
8484
path,
8585
{
86-
"Route": f"Methods: {data['methods']}\n\nReturn type: {data['return_type']}",
87-
"Extra": f"Extra: {'\n'.join([f' + {key}: {value}' for key, value in data['extra'].items()])}",
86+
"Route": (
87+
f"Methods: {data['methods']}\n\nReturn type:"
88+
f" {data['return_type']}"
89+
),
90+
"Extra": (
91+
"Extra:"
92+
f" {'\n'.join([f' + {key}: {value}' for key, value in data['extra'].items()])}"
93+
),
8894
},
8995
section,
9096
)

pyechonext/middleware.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ def to_response(self, response: Response):
9090
if not response.request.session_id:
9191
session_id = uuid4()
9292
logger.debug(
93-
f"Set session_id={session_id} for response {response.status_code} {response.request.path}"
93+
f"Set session_id={session_id} for response"
94+
f" {response.status_code} {response.request.path}"
9495
)
9596
response.add_headers(
9697
[

pyechonext/response.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ def __call__(self, environ: dict, start_response: method) -> Iterable:
160160
self._structuring_headers(environ)
161161

162162
logger.debug(
163-
f"[{environ.get('REQUEST_METHOD')} {self.status_code}] Run response: {self.content_type}"
163+
f"[{environ.get('REQUEST_METHOD')} {self.status_code}] Run response:"
164+
f" {self.content_type}"
164165
)
165166

166167
start_response(status=self.status_code, headers=self._headerslist)

pyechonext/template_engine/builtin.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
from pyechonext.utils.exceptions import TemplateNotFileError
77

88
FOR_BLOCK_PATTERN = re.compile(
9-
r"{% for (?P<variable>[a-zA-Z]+) in (?P<seq>[a-zA-Z]+) %}(?P<content>[\S\s]+)(?={% endfor %}){% endfor %}"
9+
r"{% for (?P<variable>[a-zA-Z]+) in (?P<seq>[a-zA-Z]+) %}(?P<content>[\S\s]+)(?={%"
10+
r" endfor %}){% endfor %}"
1011
)
1112
VARIABLE_PATTERN = re.compile(r"{{ (?P<variable>[a-zA-Z_]+) }}")
1213

@@ -141,7 +142,8 @@ def render_template(request: Request, template_name: str, **kwargs) -> str:
141142
:raises AssertionError: BASE_DIR and TEMPLATES_DIR is empty
142143
"""
143144
logger.warn(
144-
"Built-in template engine is under development and may be unstable or contain bugs"
145+
"Built-in template engine is under development and may be unstable or contain"
146+
" bugs"
145147
)
146148

147149
assert request.settings.BASE_DIR

pyechonext/utils/__init__.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ def print_header(msg_type: str, text: str):
1818
:type text: str
1919
"""
2020
print(
21-
f"[yellow]{'#' * len(text)}[/yellow]\n[blue]{get_current_datetime()} {msg_type.upper()}][/blue] {text}\n[yellow]{'#' * len(text)}[/yellow]\n"
21+
f"[yellow]{'#' * len(text)}[/yellow]\n[blue]{get_current_datetime()} {msg_type.upper()}][/blue]"
22+
f" {text}\n[yellow]{'#' * len(text)}[/yellow]\n"
2223
)
2324

2425

@@ -32,7 +33,8 @@ def print_step(msg_type: str, text: str):
3233
:type text: str
3334
"""
3435
print(
35-
f"[yellow]{'=' * 16}[/yellow] [blue][{get_current_datetime()} {msg_type.upper()}][/blue] {text}"
36+
f"[yellow]{'=' * 16}[/yellow]"
37+
f" [blue][{get_current_datetime()} {msg_type.upper()}][/blue] {text}"
3638
)
3739

3840

@@ -46,7 +48,8 @@ def print_substep(msg_type: str, text: str):
4648
:type text: str
4749
"""
4850
print(
49-
f"[cyan]{'=' * 8}[/cyan]\n[blue][{get_current_datetime()} {msg_type.upper()}][/blue] {text}"
51+
f"[cyan]{'=' * 8}[/cyan]\n[blue][{get_current_datetime()} {msg_type.upper()}][/blue]"
52+
f" {text}"
5053
)
5154

5255

@@ -83,7 +86,8 @@ def run_command(command: str) -> int:
8386

8487
print_message(
8588
"info",
86-
f"[italic] Execute command: [/italic]: [white on black]{command}[/white on black]",
89+
f"[italic] Execute command: [/italic]: [white on black]{command}[/white on"
90+
" black]",
8791
)
8892

8993
result = subprocess.run(
@@ -92,7 +96,8 @@ def run_command(command: str) -> int:
9296

9397
if result.returncode != 0:
9498
raise RuntimeError(
95-
f'Command "{command}" failed with exit code {result.returncode}:\n{result.stderr.decode()}'
99+
f'Command "{command}" failed with exit code'
100+
f" {result.returncode}:\n{result.stderr.decode()}"
96101
)
97102
else:
98103
print(f'[green bold]Successfully run[/green bold] "{command}"'.strip())
@@ -122,7 +127,8 @@ def validate_project_name(project_name: str):
122127
"""
123128
if not re.match(r"^[a-zA-Z_][a-zA-Z0-9_]*$", project_name):
124129
raise ValueError(
125-
"Invalid project name. Must start with a letter or underscore and contain only letters, digits, and underscores."
130+
"Invalid project name. Must start with a letter or underscore and contain"
131+
" only letters, digits, and underscores."
126132
)
127133

128134

0 commit comments

Comments
 (0)