Fixes Pyright errors introduced in the RLE patch files for azure-ai-projects.
Source PR: #47694
Failed build: [6742620 — azure-sdk/public]((dev.azure.com/redacted)
Diagnosis
Three distinct Pyright issues in the new RLE patch files:
-
Tuple not imported (_patch_rle.py:195): Tuple was used in the return type annotation of _capacity_retry but not imported from typing.
-
Attribute access on RLEInstancesOperations (both files, 14 errors): The _acquire_instance function and OpenEnvInstance/AsyncOpenEnvClient class store an instances parameter typed as RLEInstancesOperations, but call runtime methods (health, reset, step, state, get_metadata, schema) that only exist on RLEInstanceRuntimeOperations. These methods are added at runtime via setattr in RLEOperations.__init__, so Pyright cannot see them statically.
-
str | None argument mismatch (both files): _close_group_locked passes self._version (typed Optional[str]) directly to delete_instance_group(environment_version: str).
Changes
_patch_rle.py: Added Tuple to the from typing import line.
- Both files: Changed
instances: RLEInstancesOperations → instances: Any in _acquire_instance, OpenEnvInstance.__init__ / AsyncOpenEnvClient.__init__, and OpenEnvClient.__init__ / AsyncOpenEnvClient.__init__, reflecting that the object is a monkey-patched combination of both operation classes at runtime.
- Both files: Added an early-return
None guard (if self._version is None: return) in _close_group_locked before calling delete_instance_group, fixing the str | None narrowing error. This is safe because self._version is always set before any group is created (in _ensure_group).
Validation
Validation is pending the automated Pyright check triggered by the draft pull request.
To route changes like this to a review issue instead of blocking, configure protected-files: fallback-to-issue in your workflow configuration.
Generated by Pipeline Auto Fix · 110.5 AIC · ⌖ 16.2 AIC · ⊞ 7.6K · ◷
Fixes Pyright errors introduced in the RLE patch files for
azure-ai-projects.Source PR: #47694
Failed build: [6742620 — azure-sdk/public]((dev.azure.com/redacted)
Diagnosis
Three distinct Pyright issues in the new RLE patch files:
Tuplenot imported (_patch_rle.py:195):Tuplewas used in the return type annotation of_capacity_retrybut not imported fromtyping.Attribute access on
RLEInstancesOperations(both files, 14 errors): The_acquire_instancefunction andOpenEnvInstance/AsyncOpenEnvClientclass store aninstancesparameter typed asRLEInstancesOperations, but call runtime methods (health,reset,step,state,get_metadata,schema) that only exist onRLEInstanceRuntimeOperations. These methods are added at runtime viasetattrinRLEOperations.__init__, so Pyright cannot see them statically.str | Noneargument mismatch (both files):_close_group_lockedpassesself._version(typedOptional[str]) directly todelete_instance_group(environment_version: str).Changes
_patch_rle.py: AddedTupleto thefrom typing importline.instances: RLEInstancesOperations→instances: Anyin_acquire_instance,OpenEnvInstance.__init__/AsyncOpenEnvClient.__init__, andOpenEnvClient.__init__/AsyncOpenEnvClient.__init__, reflecting that the object is a monkey-patched combination of both operation classes at runtime.Noneguard (if self._version is None: return) in_close_group_lockedbefore callingdelete_instance_group, fixing thestr | Nonenarrowing error. This is safe becauseself._versionis always set before any group is created (in_ensure_group).Validation
Validation is pending the automated Pyright check triggered by the draft pull request.
Warning
Protected Files
This was originally intended as a pull request, but the patch modifies protected files. These files may affect project dependencies, CI/CD pipelines, or agent behaviour. Please review the changes carefully before creating the pull request.
Click here to create the pull request once you have reviewed the changes
Protected files
CHANGELOG.mdTo route changes like this to a review issue instead of blocking, configure
protected-files: fallback-to-issuein your workflow configuration.