Skip to content

Fix argument types and improve message retrieval method#754

Merged
yuji38kwmt merged 2 commits into
mainfrom
290260549
May 9, 2026
Merged

Fix argument types and improve message retrieval method#754
yuji38kwmt merged 2 commits into
mainfrom
290260549

Conversation

@yuji38kwmt
Copy link
Copy Markdown
Collaborator

No description provided.

@yuji38kwmt yuji38kwmt enabled auto-merge (squash) May 9, 2026 00:43
@kci-pr-agent
Copy link
Copy Markdown

kci-pr-agent Bot commented May 9, 2026

Title

Fix argument types and improve message retrieval method


Description

  • 引数型をdictからInternationalizationMessageに変更

  • messages取得のcast削除、直接代入に改修

  • Lang/STR_LANG判定は継続


Changes walkthrough 📝

Relevant files
Enhancement
annotation_specs.py`
get_message_with_lang型修正と取得簡略化                                                     

annofabapi/util/annotation_specs.py

  • get_message_with_langの引数型をdictからInternationalizationMessageに限定
  • messages取得時のcastを削除し直接代入
  • 既存のLang/STR_LANG判定ロジックを維持
  • Additional files
    annotation_specs.py +2/-2     

    Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • @kci-pr-agent
    Copy link
    Copy Markdown

    kci-pr-agent Bot commented May 9, 2026

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    後方互換性破壊

    関数シグネチャからdict[str, Any]を除外したことで、以前は辞書型を渡していたコードが動作しなくなる可能性があります。呼び出し元が常にInternationalizationMessageオブジェクトを渡しているか確認してください。

    def get_message_with_lang(internationalization_message: InternationalizationMessage, lang: Lang | STR_LANG) -> str | None:
    messagesキーの存在チェック

    internationalization_message["messages"]を直接参照すると、messagesキーが欠落している場合にKeyErrorが発生します。キーの存在確認や例外処理の追加を検討してください。

    messages = internationalization_message["messages"]


    """
    messages = cast(list[InternationalizationMessageItem], internationalization_message["messages"])
    messages = internationalization_message["messages"]
    Copy link
    Copy Markdown

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Suggestion: InternationalizationMessageが辞書型ではなく属性アクセスを想定する場合、["messages"]ではなく属性のmessagesを使うことで実行時エラーを回避できます。 [possible issue, importance: 8]

    Suggested change
    messages = internationalization_message["messages"]
    messages = internationalization_message.messages


    """
    messages = cast(list[InternationalizationMessageItem], internationalization_message["messages"])
    messages = internationalization_message["messages"]
    Copy link
    Copy Markdown

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Suggestion: 取得したmessagesがリストであることを確認し、想定外の型だった場合にNoneを返すことで安全性を高めます。 [possible issue, importance: 4]

    Suggested change
    messages = internationalization_message["messages"]
    messages = internationalization_message["messages"]
    if not isinstance(messages, list):
    return None

    @yuji38kwmt yuji38kwmt merged commit 93209e0 into main May 9, 2026
    8 checks passed
    @yuji38kwmt yuji38kwmt deleted the 290260549 branch May 9, 2026 01:02
    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