Skip to content

Commit 90f8d4b

Browse files
Евгений БлиновЕвгений Блинов
authored andcommitted
Refactor building module imports and fix insert logic
1 parent d865486 commit 90f8d4b

File tree

6 files changed

+9
-11
lines changed

6 files changed

+9
-11
lines changed

metacode/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1+
from metacode.building import build as build
2+
from metacode.building import insert as insert
13
from metacode.errors import UnknownArgumentTypeError as UnknownArgumentTypeError
24
from metacode.parsing import ParsedComment as ParsedComment
35
from metacode.parsing import parse as parse
4-
from metacode.building import build as build, insert as insert

metacode/building.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from ast import AST
22

3-
from metacode.typing import EllipsisType
43
from metacode import ParsedComment
4+
from metacode.typing import EllipsisType
55

66

77
def build(comment: ParsedComment) -> str:
@@ -42,7 +42,6 @@ def insert(comment: ParsedComment, existing_comment: str, at_end: bool = False)
4242
return existing_comment + build(comment)
4343
return f'{existing_comment} {build(comment)}'
4444

45-
else:
46-
if existing_comment.startswith(' '):
47-
return f'{build(comment)}{existing_comment}'
48-
return f'{build(comment)} {existing_comment}'
45+
if existing_comment.startswith(' '):
46+
return f'{build(comment)}{existing_comment}'
47+
return f'{build(comment)} {existing_comment}'

metacode/comment.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
from ast import AST
21
from dataclasses import dataclass
3-
from typing import List, Optional
42

53
from metacode.typing import Arguments
64

metacode/parsing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
from libcst import SimpleStatementLine
66
from libcst import parse_module as cst_parse
77

8+
from metacode.comment import ParsedComment
89
from metacode.errors import UnknownArgumentTypeError
910
from metacode.typing import Arguments
10-
from metacode.comment import ParsedComment
1111

1212

1313
def get_right_part(comment: str) -> str:

metacode/typing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from ast import AST
2-
from typing import Union, TypeAlias, List, Optional
2+
from typing import List, Optional, TypeAlias, Union
33

44
# TODO: delete this catch block and "type: ignore" if minimum supported version of Python is > 3.9.
55
try:

tests/test_building.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import pytest
44
from full_match import match
55

6-
from metacode import build, insert, ParsedComment
6+
from metacode import ParsedComment, build, insert
77

88

99
def test_run_build_with_wrong_key_or_action():

0 commit comments

Comments
 (0)