Skip to content

[Qna] fix pylint/pyright for next version#44887

Merged
amber-Chen-86 merged 11 commits intoAzure:mainfrom
amber-Chen-86:v-amber/fix-pylint-pyright-qna
Feb 3, 2026
Merged

[Qna] fix pylint/pyright for next version#44887
amber-Chen-86 merged 11 commits intoAzure:mainfrom
amber-Chen-86:v-amber/fix-pylint-pyright-qna

Conversation

@amber-Chen-86
Copy link
Member

Description

Please add an informative description that covers that changes made by the pull request and link all relevant issues.

If an SDK is being regenerated based on a new API spec, a link to the pull request containing these API spec changes should be included above.

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

Copy link
Contributor

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 addresses pylint and pyright static analysis warnings in the azure-ai-language-questionanswering SDK. The changes focus on improving type safety and code quality without introducing functional changes.

Changes:

  • Replaced unsafe eval() usage in serialization with explicit type conversion
  • Fixed type safety issues with type comparisons and casting
  • Removed unused test fixture parameters
  • Added pylint disable comments for intentional violations
  • Implemented array encoding/decoding functionality and deserialization caching for mutable types

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
tests/testcase.py Added pylint disable comment for constant test warning
tests/test_query_text.py Moved imports to top, removed unused recorded_test fixture, added pylint disable comments
tests/test_query_knowledgebase_async.py Moved imports to top, removed unused recorded_test fixture, simplified list comprehensions
tests/test_query_knowledgebase.py Moved imports to top, removed unused recorded_test fixture, added pylint disable comments
azure/ai/language/questionanswering/_utils/serialization.py Replaced eval() with explicit conditionals, added cast() for type safety, improved error messages
azure/ai/language/questionanswering/_utils/model_base.py Added array encoding support, deserialization caching for mutable types, type annotation improvements, changed type(None) comparisons to use constant
Comments suppressed due to low confidence (1)

sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/_utils/model_base.py:410

  • The __delitem__ method should clear any cached deserialized value when deleting a key, similar to how __setitem__ does. Without this, a stale cache attribute could remain on the object after deletion, potentially causing issues if the key is re-added later.
    def __delitem__(self, key: str) -> None:
        self._data.__delitem__(key)

@amber-Chen-86 amber-Chen-86 marked this pull request as ready for review January 28, 2026 21:53
@sarkar-rajarshi
Copy link
Member

/azp run python - cognitivelanguage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@amber-Chen-86
Copy link
Member Author

/check-enforcer override

@amber-Chen-86
Copy link
Member Author

The pipeline Pyright failures are unrelated to this PR.

@scbedd
Copy link
Member

scbedd commented Feb 2, 2026

/check-enforcer override

Clean pr run. The failing cognitive language was manually queued, and is failing from a different package.

@amber-Chen-86 amber-Chen-86 merged commit e582f4d into Azure:main Feb 3, 2026
46 checks passed
@amber-Chen-86 amber-Chen-86 deleted the v-amber/fix-pylint-pyright-qna branch February 3, 2026 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants