Skip to content

Fix pyright and pylint errors in evaluator upload operations#45867

Merged
dargilco merged 3 commits intoAzure:feature/azure-ai-projects/2.0.2from
w-javed:fix/evaluator-upload-lint-errors
Mar 24, 2026
Merged

Fix pyright and pylint errors in evaluator upload operations#45867
dargilco merged 3 commits intoAzure:feature/azure-ai-projects/2.0.2from
w-javed:fix/evaluator-upload-lint-errors

Conversation

@w-javed
Copy link
Contributor

@w-javed w-javed commented Mar 24, 2026

Summary

Fixes pyright and pylint errors in the evaluator upload code added in PR #45678.

Changes

  • error_code access: Replace hasattr(e, 'error_code') with getattr(e, 'error_code', None) to fix pyright reportAttributeAccessIssue on HttpResponseError (attribute is dynamically set by azure-storage-blob)
  • Type narrowing: Use isinstance checks for EvaluatorVersion and CodeBasedEvaluatorDefinition to fix pyright type errors on definition/blob_uri access
  • Too many locals: Extract _upload_folder_to_blob() and _set_blob_uri() helper methods to fix pylint R0914
  • Tests: Update mocks to use MagicMock(spec=CodeBasedEvaluatorDefinition)

Verification

  • Pyright: 0 errors
  • Pylint: 9.79/10 (only R0801 sync/async duplication remains — expected) ✅
  • Tests: 42/42 passing (21 sync + 21 async) ✅

- Replace hasattr(e, 'error_code') with getattr(e, 'error_code', None) to
  fix pyright reportAttributeAccessIssue on HttpResponseError
- Narrow union types with isinstance checks for EvaluatorVersion and
  CodeBasedEvaluatorDefinition to fix pyright type errors on definition/blob_uri
- Extract _upload_folder_to_blob() and _set_blob_uri() helpers to fix pylint
  R0914 (too many local variables) in upload()
- Update tests to use MagicMock(spec=CodeBasedEvaluatorDefinition) for
  definition mocks

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Fix C4739/C4741/C4742 violations from azure-pylint-guidelines-checker:
- _set_blob_uri: add :param and :type for evaluator_version, blob_uri
- _start_pending_upload_and_get_container_client: add :param/:type/:return/:rtype
- _get_next_version: add :param/:type/:return/:rtype

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dargilco dargilco merged commit b035800 into Azure:feature/azure-ai-projects/2.0.2 Mar 24, 2026
20 checks passed
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.

2 participants