Skip to content

Commit b1a82d5

Browse files
mypy-next pylint-next and mypy samples (Azure#40155)
* mypy-next pylint-next and mypy samples * black fixes * re trigger build
1 parent aa5ecc4 commit b1a82d5

13 files changed

+47
-54
lines changed

sdk/ml/azure-ai-ml/azure/ai/ml/entities/_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ def get_rest_dict_for_node_attrs(
357357
from azure.ai.ml.entities._job.pipeline._io import PipelineInput
358358

359359
if target_obj is None:
360-
return None
360+
return None # type:ignore
361361
if isinstance(target_obj, dict):
362362
result_dict: dict = {}
363363
for key, value in target_obj.items():

sdk/ml/azure-ai-ml/azure/ai/ml/identity/_aio/_credentials/aml_on_behalf_of.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,17 @@ async def close(self) -> None:
5353

5454

5555
class _AzureMLOnBehalfOfCredential(AsyncManagedIdentityBase):
56-
def get_client(self, **kwargs):
57-
# type: (**Any) -> Optional[AsyncManagedIdentityClient]
56+
def get_client(self, **kwargs) -> Optional[AsyncManagedIdentityClient]:
5857
client_args = _get_client_args(**kwargs)
5958
if client_args:
6059
return AsyncManagedIdentityClient(**client_args)
6160
return None
6261

63-
def get_unavailable_message(self):
64-
# type: () -> str
62+
def get_unavailable_message(self) -> str:
6563
return "AzureML On Behalf of credentials not available in this environment"
6664

6765

68-
def _get_client_args(**kwargs):
69-
# type: (dict) -> Optional[dict]
66+
def _get_client_args(**kwargs) -> Optional[dict]:
7067

7168
url = os.environ.get("OBO_ENDPOINT")
7269
if not url:
@@ -79,8 +76,7 @@ def _get_client_args(**kwargs):
7976
)
8077

8178

82-
def _get_request(url, resource):
83-
# type: (str, str) -> HttpRequest
79+
def _get_request(url: str, resource: str) -> HttpRequest:
8480
request = HttpRequest("GET", url)
8581
request.format_parameters(dict({"resource": resource}))
8682
return request

sdk/ml/azure-ai-ml/azure/ai/ml/identity/_credentials/aml_on_behalf_of.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,27 +54,23 @@ def __enter__(self) -> "AzureMLOnBehalfOfCredential":
5454
def __exit__(self, *args: Any) -> None:
5555
self._credential.__exit__(*args)
5656

57-
def close(self):
58-
# type: () -> None
57+
def close(self) -> None:
5958
"""Close the credential's transport session."""
6059
self.__exit__()
6160

6261

6362
class _AzureMLOnBehalfOfCredential(ManagedIdentityBase):
64-
def get_client(self, **kwargs):
65-
# type: (**Any) -> Optional[ManagedIdentityClient]
63+
def get_client(self, **kwargs) -> Optional[ManagedIdentityClient]:
6664
client_args = _get_client_args(**kwargs)
6765
if client_args:
6866
return ManagedIdentityClient(**client_args)
6967
return None
7068

71-
def get_unavailable_message(self):
72-
# type: () -> str
69+
def get_unavailable_message(self) -> str:
7370
return "AzureML On Behalf of credentials not available in this environment"
7471

7572

76-
def _get_client_args(**kwargs):
77-
# type: (dict) -> Optional[dict]
73+
def _get_client_args(**kwargs) -> Optional[dict]:
7874

7975
url = os.environ.get("OBO_ENDPOINT")
8076
if not url:
@@ -87,8 +83,7 @@ def _get_client_args(**kwargs):
8783
)
8884

8985

90-
def _get_request(url, resource):
91-
# type: (str, str) -> HttpRequest
86+
def _get_request(url: str, resource: str) -> HttpRequest:
9287
request = HttpRequest("GET", url)
9388
request.format_parameters(dict({"resource": resource}))
9489
return request

sdk/ml/azure-ai-ml/azure/ai/ml/operations/_model_operations.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -452,10 +452,10 @@ def download(self, name: str, version: str, download_path: Union[PathLike, str]
452452
from azure.identity import ClientSecretCredential
453453

454454
token_credential = ClientSecretCredential(
455-
tenant_id=ds.credentials["tenant_id"],
456-
client_id=ds.credentials["client_id"],
457-
client_secret=ds.credentials["client_secret"],
458-
authority=ds.credentials["authority_url"],
455+
tenant_id=ds.credentials["tenant_id"], # type:ignore
456+
client_id=ds.credentials["client_id"], # type:ignore
457+
client_secret=ds.credentials["client_secret"], # type:ignore
458+
authority=ds.credentials["authority_url"], # type:ignore
459459
)
460460
credential = token_credential
461461
except (KeyError, TypeError):

sdk/ml/azure-ai-ml/samples/ml_samples_capability_host.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def ml_capability_host_config(self):
170170
resource_group,
171171
workspace_name=hub_name,
172172
)
173-
capability_hosts = ml_client.capability_hosts.list()
173+
capability_hosts = ml_client.capability_hosts.list() # type:ignore
174174

175175
# List CapabilityHosts created in Project
176176
ml_client = MLClient(
@@ -179,7 +179,7 @@ def ml_capability_host_config(self):
179179
resource_group,
180180
workspace_name=project_name,
181181
)
182-
capability_hosts = ml_client.capability_hosts.list()
182+
capability_hosts = ml_client.capability_hosts.list() # type:ignore
183183
# [END capability_host_list_operation]
184184

185185

sdk/ml/azure-ai-ml/samples/ml_samples_cloud_configurations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def ml_cloud_config_from_keyword_args(self):
7171
subscription_id=subscription_id,
7272
resource_group_name=resource_group,
7373
workspace_name="test-ws1",
74-
**kwargs,
74+
**kwargs, # type:ignore
7575
)
7676
# The client will use the cloud that we passed in
7777
print("Client is using cloud:", ml_client._cloud)

sdk/ml/azure-ai-ml/samples/ml_samples_compute.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def ml_compute_config_setup_3(self):
156156
# [START compute_instance_ssh_settings]
157157
from azure.ai.ml.entities import ComputeInstanceSshSettings
158158

159-
ssh_settings = ComputeInstanceSshSettings(
159+
ssh_settings = ComputeInstanceSshSettings( # type:ignore
160160
ssh_key_value="ssh-rsa ABCDEFGHIJKLMNOPQRSTUVWXYZ administrator@MININT-2023"
161161
)
162162
# [END compute_instance_ssh_settings]
@@ -178,7 +178,7 @@ def ml_compute_config_setup_3(self):
178178
# [START vm_ssh_settings]
179179
from azure.ai.ml.entities import VirtualMachineSshSettings
180180

181-
ssh_settings = VirtualMachineSshSettings(
181+
ssh_settings = VirtualMachineSshSettings( # type:ignore
182182
admin_username="azureuser",
183183
admin_password="azureuserpassword",
184184
ssh_port=8888,
@@ -192,7 +192,7 @@ def ml_compute_config_setup_3(self):
192192
vm_compute = VirtualMachineCompute(
193193
name="vm-compute",
194194
resource_id="/subscriptions/123456-1234-1234-1234-123456789/resourceGroups/my-rg/providers/Microsoft.Compute/virtualMachines/my-vm",
195-
ssh_settings=ssh_settings,
195+
ssh_settings=ssh_settings, # type:ignore
196196
)
197197
# [END vm_compute]
198198

sdk/ml/azure-ai-ml/samples/ml_samples_genAI_monitors_configuration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def ml_gen_ai_monitor_advance(self):
122122
monitor_settings = MonitorDefinition(
123123
compute=spark_compute,
124124
monitoring_target=monitoring_target,
125-
monitoring_signals=monitoring_signals,
125+
monitoring_signals=monitoring_signals, # type:ignore
126126
alert_notification=alert_notification,
127127
)
128128

sdk/ml/azure-ai-ml/samples/ml_samples_misc.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def ml_misc_config_0(self):
6666
from azure.ai.ml import load_job
6767
from azure.ai.ml.entities import PipelineJob
6868

69-
pipeline_job: PipelineJob = load_job(
69+
pipeline_job: PipelineJob = load_job( # type:ignore
7070
"./sdk/ml/azure-ai-ml/tests/test_configs/pipeline_jobs/invalid/combo.yml",
7171
params_override=[{"name": job_name}, {"compute": "cpucluster"}],
7272
)
@@ -132,7 +132,7 @@ def ml_misc_config_0(self):
132132
output_file_name="output-file-name",
133133
environment_variables={"env1": "value1", "env2": "value2"},
134134
error_threshold=2,
135-
logging_level=1,
135+
logging_level="1",
136136
)
137137
# [END model_batch_deployment_settings_entity_create]
138138

@@ -151,7 +151,7 @@ def ml_misc_config_0(self):
151151
# [START model_package_entity_create]
152152
from azure.ai.ml.entities import AzureMLOnlineInferencingServer, CodeConfiguration, ModelPackage
153153

154-
modelPackage = ModelPackage(
154+
modelPackage = ModelPackage( # type:ignore
155155
inferencing_server=AzureMLOnlineInferencingServer(
156156
code_configuration=CodeConfiguration(code="../model-1/foo/", scoring_script="score.py")
157157
),
@@ -321,7 +321,9 @@ def ml_misc_config_0(self):
321321
from azure.ai.ml import load_job
322322
from azure.ai.ml.entities import JobSchedule, RecurrencePattern, RecurrenceTrigger
323323

324-
pipeline_job = load_job("./sdk/ml/azure-ai-ml/tests/test_configs/command_job/command_job_test_local_env.yml")
324+
pipeline_job = load_job(
325+
"./sdk/ml/azure-ai-ml/tests/test_configs/command_job/command_job_test_local_env.yml"
326+
) # type:ignore
325327
trigger = RecurrenceTrigger(
326328
frequency="week",
327329
interval=4,
@@ -337,7 +339,7 @@ def ml_misc_config_0(self):
337339
from azure.ai.ml.constants import TimeZone
338340
from azure.ai.ml.entities import CronTrigger
339341

340-
trigger = CronTrigger(
342+
trigger = CronTrigger( # type:ignore
341343
expression="15 10 * * 1",
342344
start_time=datetime(year=2022, month=3, day=10, hour=10, minute=15),
343345
end_time=datetime(year=2022, month=6, day=10, hour=10, minute=15),

sdk/ml/azure-ai-ml/samples/ml_samples_pipeline_job_configurations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def ml_pipeline_config(self):
5050
)
5151

5252
# Define a pipeline with decorator
53-
@pipeline(name="sample_pipeline", description="pipeline description")
53+
@pipeline(name="sample_pipeline", description="pipeline description") # type:ignore
5454
def sample_pipeline_func(pipeline_input1, pipeline_input2):
5555
# component1 and component2 will be added into the current pipeline
5656
component1 = component_func(component_in_number=pipeline_input1, component_in_path=uri_file_input)

0 commit comments

Comments
 (0)