Skip to content

attribute_restrictions.py : リファクタリング #713

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 10 commits into from
Apr 2, 2025
Merged

Conversation

yuji38kwmt
Copy link
Collaborator

No description provided.

@yuji38kwmt yuji38kwmt requested a review from Copilot April 2, 2025 05:37
Copy link

@Copilot Copilot AI left a 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 standardizes naming conventions for attribute restrictions and improves error messaging while introducing an AttributeFactory for a more consistent API.

  • Renamed instances of StringTextBox and IntegerTextBox to StringTextbox and IntegerTextbox across tests and the core module.
  • Introduced an AttributeFactory class to streamline the creation of attribute restriction objects.
  • Enhanced error messages and argument validations in functions get_choice, get_attribute, and get_label.

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.

File Description
tests/util/test_attribute_restrictions.py Updated tests to use the new naming conventions for textbox types.
tests/util/test_annotation_specs.py Added tests for get_choice and error scenarios for annotation specs.
annofabapi/util/attribute_restrictions.py Renamed classes and added the AttributeFactory for attribute creation.
annofabapi/util/annotation_specs.py Improved argument validation and error messages for spec getters.
Files not reviewed (1)
  • .vscode/settings.json: Language not supported
Comments suppressed due to low confidence (1)

annofabapi/util/annotation_specs.py:84

  • [nitpick] Consider rephrasing the error message for clarity, for example: "Exactly one of 'choice_id' or 'choice_name' must be provided." This will improve readability and consistency with similar validations.
raise ValueError("'choice_id'か'choice_name'のどちらかはNone以外にしてください。")

@yuji38kwmt yuji38kwmt changed the title Restrictions attribute_restrictions.py : リファクタリング Apr 2, 2025
@yuji38kwmt yuji38kwmt enabled auto-merge (squash) April 2, 2025 05:48
@yuji38kwmt yuji38kwmt merged commit ff6bd52 into main Apr 2, 2025
7 checks passed
@yuji38kwmt yuji38kwmt deleted the restrictions branch April 2, 2025 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant