Skip to content

Commit 45e8bc4

Browse files
authored
AttributeFactoryのコンストラクタ引数を変更 (#714)
* add * format * poetry update * `AnnotationSpecsAccessor`に属性を追加
1 parent ff6bd52 commit 45e8bc4

File tree

5 files changed

+257
-205
lines changed

5 files changed

+257
-205
lines changed

.vscode/cspell.json

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"pydantic",
3434
"pydata",
3535
"pylint",
36+
"pytest",
3637
"relativedelta",
3738
"timespec",
3839
"tzlocal",

annofabapi/util/annotation_specs.py

+1
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ class AnnotationSpecsAccessor:
147147
"""
148148

149149
def __init__(self, annotation_specs: dict[str, Any]) -> None:
150+
self.annotation_specs = annotation_specs
150151
self.labels = annotation_specs["labels"]
151152
self.additionals = annotation_specs["additionals"]
152153

annofabapi/util/attribute_restrictions.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
99
>>> import annofabapi
1010
>>> from annofabapi.util.annotation_specs import AnnotationSpecsAccessor
11-
>>> from annofabapi.util.attribute_restrictions import AttributeFactory
1211
>>> service = annofabapi.build()
1312
>>> annotation_specs, _ = service.api.get_annotation_specs("prj1", query_params={"v": "3"})
14-
>>> fac = AttributeFactory(AnnotationSpecsAccessor(annotation_specs))
13+
>>> fac = AttributeFactory(annotation_specs)
1514
1615
# 「'occluded'チェックボックスがONならば、'note'テキストボックスは空ではない」という制約
1716
>>> premise_restriction = fac.checkbox(attribute_name="occluded").checked()
@@ -295,11 +294,11 @@ class AttributeFactory:
295294
属性を生成するためのFactoryクラス
296295
297296
Attributes:
298-
accessor: アノテーション仕様のアクセサ
297+
annotation_specs: アノテーション仕様(v3)の情報
299298
"""
300299

301-
def __init__(self, accessor: AnnotationSpecsAccessor) -> None:
302-
self.accessor = accessor
300+
def __init__(self, annotation_specs: dict[str, Any]) -> None:
301+
self.accessor = AnnotationSpecsAccessor(annotation_specs)
303302

304303
def checkbox(self, *, attribute_id: Optional[str] = None, attribute_name: Optional[str] = None) -> Checkbox:
305304
return Checkbox(self.accessor, attribute_id=attribute_id, attribute_name=attribute_name)

0 commit comments

Comments
 (0)