Skip to content

Commit 1fc0903

Browse files
committed
UPDATE
1 parent 8f8d883 commit 1fc0903

File tree

5 files changed

+17
-16
lines changed

5 files changed

+17
-16
lines changed

schema_entry/entrypoint.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
from yaml import load as yaml_load
2424

2525
from .protocol import SUPPORT_SCHEMA
26-
from .utils import SchemaType, get_parent_tree, parse_value_string_by_schema, parse_schema_as_cmd
27-
from .entrypoint_base import EntryPointABC
26+
from .utils import get_parent_tree, parse_value_string_by_schema, parse_schema_as_cmd
27+
from .entrypoint_base import SchemaType, EntryPointABC
2828

2929

3030
class EntryPoint(EntryPointABC):
@@ -125,10 +125,12 @@ def __init__(self, *,
125125
self._config_file_parser_map = config_file_parser_map
126126
if main is not None:
127127
self._main = main
128+
else:
129+
self._main = None
128130

129131
self._check_schema()
130132
self._subcmds = {}
131-
self._main = None
133+
132134
self._config = {}
133135

134136
@ property

schema_entry/entrypoint_base.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@
22
import abc
33
import argparse
44
from pathlib import Path
5-
from typing import Callable, Sequence, Dict, Any, Optional, Tuple
6-
from .utils import SchemaType
5+
from typing import Callable, Sequence, Dict, Any, Optional, Tuple, List
6+
from mypy_extensions import TypedDict
7+
8+
9+
class SchemaType(TypedDict):
10+
required: List[str]
11+
type: str
12+
properties: Dict[str, Dict[str, Any]]
713

814

915
class EntryPointABC(abc.ABC):

schema_entry/utils.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,9 @@
55
import warnings
66
import argparse
77
from typing import List, Dict, Any, Optional
8-
from mypy_extensions import TypedDict
98
from .entrypoint_base import EntryPointABC
109

1110

12-
class SchemaType(TypedDict):
13-
required: List[str]
14-
type: str
15-
properties: Dict[str, Dict[str, Any]]
16-
17-
1811
def _get_parent_tree(c: EntryPointABC, result: List[str]) -> None:
1912
if c.parent:
2013
result.append(c.parent.name)

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = schema_entry
3-
version = 0.1.1
3+
version = 0.1.2
44
url = https://github.com/Python-Tools/schema_entry
55
author = hsz
66
author_email = hsz1273327@gmail.com

tests/test_entrypoint_without_subclass.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def test_load_json_configfile(self) -> None:
130130
str(Path.home().joinpath(".test_config.json")),
131131
"./test_config.json"
132132
],
133-
main=lambda a_a: None)
133+
main=lambda a: None)
134134
root([])
135135
self.assertDictEqual(root.config, {
136136
"a": 1
@@ -155,7 +155,7 @@ def test_load_json_configfile_onlyneed(self) -> None:
155155
},
156156
"required": ["a"]
157157
},
158-
main=lambda a_a: None
158+
main=lambda a: None
159159
)
160160
root([])
161161
self.assertDictEqual(root.config, {
@@ -170,7 +170,7 @@ def test_load_yaml_configfile(self) -> None:
170170
str(Path.home().joinpath(".test_config.yml")),
171171
"./test_config.yml"
172172
],
173-
main=lambda a_a: None
173+
main=lambda a: None
174174
)
175175

176176
root([])

0 commit comments

Comments
 (0)