Skip to content

AttributeFactoryのコンストラクタ引数を変更 #714

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"pydantic",
"pydata",
"pylint",
"pytest",
"relativedelta",
"timespec",
"tzlocal",
Expand Down
1 change: 1 addition & 0 deletions annofabapi/util/annotation_specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ class AnnotationSpecsAccessor:
"""

def __init__(self, annotation_specs: dict[str, Any]) -> None:
self.annotation_specs = annotation_specs
self.labels = annotation_specs["labels"]
self.additionals = annotation_specs["additionals"]

Expand Down
9 changes: 4 additions & 5 deletions annofabapi/util/attribute_restrictions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@

>>> import annofabapi
>>> from annofabapi.util.annotation_specs import AnnotationSpecsAccessor
>>> from annofabapi.util.attribute_restrictions import AttributeFactory
>>> service = annofabapi.build()
>>> annotation_specs, _ = service.api.get_annotation_specs("prj1", query_params={"v": "3"})
>>> fac = AttributeFactory(AnnotationSpecsAccessor(annotation_specs))
>>> fac = AttributeFactory(annotation_specs)

# 「'occluded'チェックボックスがONならば、'note'テキストボックスは空ではない」という制約
>>> premise_restriction = fac.checkbox(attribute_name="occluded").checked()
Expand Down Expand Up @@ -295,11 +294,11 @@ class AttributeFactory:
属性を生成するためのFactoryクラス

Attributes:
accessor: アノテーション仕様のアクセサ
annotation_specs: アノテーション仕様(v3)の情報
"""

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

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