-
Notifications
You must be signed in to change notification settings - Fork 2
属性の制約に関するモジュールattribute_restrictions
を追加しました。
#707
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
Conversation
attribute_restrictions
を追加しました。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new module for attribute restrictions, which allows outputting constraint information based on attribute names. The changes include:
- Adding the attribute_restrictions module with various restriction classes (e.g., Checkbox, StringTextBox, IntegerTextBox, AnnotationLink, TrackingId, and Selection) and their corresponding behaviors.
- Implementing tests in tests/util/test_local_attribute_restrictions.py to validate the new attribute constraints.
- Minor updates in annotation_specs.py and pyproject.toml (e.g., enabling column number display) to support and document the new functionality.
Reviewed Changes
Copilot reviewed 5 out of 7 changed files in this pull request and generated no comments.
File | Description |
---|---|
tests/util/test_local_attribute_restrictions.py | New tests validating the behavior of attribute restriction methods. |
annofabapi/util/attribute_restrictions.py | New module defining attribute restriction classes and their methods. |
annofabapi/util/annotation_specs.py | Updated helper functions to support the new attribute restrictions. |
pyproject.toml | Minor configuration change to show column numbers in diagnostics. |
Files not reviewed (2)
- docs/api_reference/index.rst: Language not supported
- docs/api_reference/util.rst: Language not supported
Comments suppressed due to low confidence (1)
annofabapi/util/annotation_specs.py:1
- [nitpick] The docstring refers to 'InternalizationMessage' whereas the parameter is named 'internationalization_message'. Consider updating the term to 'InternationalizationMessage' for consistency.
def get_english_message(internationalization_message: dict[str, Any]) -> str:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request adds a new module for defining attribute restrictions, enabling constraints to be specified using both attribute IDs and English names. It also introduces comprehensive tests for these new restrictions and updates utility functions in the annotation specs module to support the new behavior.
- Added the module annofabapi/util/attribute_restrictions.py with various attribute restriction classes (e.g., Checkbox, StringTextBox, IntegerTextBox, etc.) and their corresponding methods.
- Introduced tests in tests/util/test_local_attribute_restrictions.py covering the functionality of each restriction class, including implications between restrictions.
- Updated the annotation specs utilities to enhance clarity and consistency when retrieving attribute and label information.
Reviewed Changes
Copilot reviewed 5 out of 7 changed files in this pull request and generated no comments.
File | Description |
---|---|
tests/util/test_local_attribute_restrictions.py | New tests for the attribute restrictions module |
annofabapi/util/attribute_restrictions.py | New module providing classes and methods for attribute constraints |
annofabapi/util/annotation_specs.py | Updated functions to support English message retrieval and choice lookup |
pyproject.toml | Enabled column number display for improved lint output |
Files not reviewed (2)
- docs/api_reference/index.rst: Language not supported
- docs/api_reference/util.rst: Language not supported
Comments suppressed due to low confidence (1)
tests/util/test_local_attribute_restrictions.py:66
- The test method name 'test__not_matches' is misleading because it validates the 'not_equals' functionality; consider renaming it to 'test__not_equals' for clarity.
def test__not_matches(self):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new module, attribute_restrictions, to provide a structured way to define constraints on attributes by supporting both ID- and English name–based representations. Key changes include:
- Adding various attribute classes (e.g., Checkbox, StringTextBox, IntegerTextBox, Selection, TrackingId) with methods that output constraint definitions.
- Implementing and testing an imply method for chaining restrictions, along with error handling for unsupported chaining.
- Updating annotation_specs helper functions and pyproject.toml configuration.
Reviewed Changes
Copilot reviewed 5 out of 7 changed files in this pull request and generated no comments.
File | Description |
---|---|
tests/util/test_local_attribute_restrictions.py | New tests covering attribute restriction methods and error handling for type checks. |
annofabapi/util/attribute_restrictions.py | New module providing restrictions implementations and chaining via imply method. |
annofabapi/util/annotation_specs.py | Updates to support internationalized messages and retrieval of attribute/choice info. |
pyproject.toml | Minor configuration update to show column numbers in linting output. |
Files not reviewed (2)
- docs/api_reference/index.rst: Language not supported
- docs/api_reference/util.rst: Language not supported
属性間の制約を設定するには、ユーザー自身でJSONを作成する必要があります。
自分でJSONを書く場合、以下の問題があります。
上記の問題を解決するため、属性の制約を定義できるモジュールを作成しました。
このモジュールの特徴は以下の通りです。
IDだけでなく英語名で表現できる
利用できない制約に対応するメソッドは定義されていない
属性のUIに対応したメソッドが定義されている。たとえば「チェックボックスがON」という制約は、
checked()
というメソッドで表現できる