Skip to content

Commit bf08066

Browse files
authored
32851: Fix mypy errors for azure-maps-render (#34987)
* 32851: Fix mypy errors for azure-maps-render * 32851: Enable type check for azure-maps-render * 32851: Revert changes for eventgrid * Use os.getenv default value to avoid unset env vars * 32851: Use generated model instead of the custom one * Update sdk/maps/azure-maps-render/samples/async_samples/sample_authentication_async.py * 32851: Update assets.json for each package to point to the latest recordings * 32851: Fix pylint errors for azure-maps-search * 32851: Revert changes in assets.json for each package * 32851: Ignore mypy errors in azure-maps-search and azure-maps-route packages
1 parent 542ec28 commit bf08066

30 files changed

+79
-72
lines changed

sdk/maps/azure-maps-geolocation/samples/async_samples/sample_authentication_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ async def authentication_maps_service_client_with_subscription_key_credential_as
3131
from azure.core.credentials import AzureKeyCredential
3232
from azure.maps.geolocation.aio import MapsGeolocationClient
3333

34-
subscription_key = os.getenv("AZURE_SUBSCRIPTION_KEY") or "your subscription key"
34+
subscription_key = os.getenv("AZURE_SUBSCRIPTION_KEY", "your subscription key")
3535

3636
maps_geolocation_client = MapsGeolocationClient(credential=AzureKeyCredential(subscription_key))
3737
# [END create_maps_geolocation_service_client_with_key_async]

sdk/maps/azure-maps-geolocation/samples/async_samples/sample_get_country_code_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import asyncio
2020
import os
2121

22-
subscription_key = os.getenv("AZURE_SUBSCRIPTION_KEY") or "your subscription key"
22+
subscription_key = os.getenv("AZURE_SUBSCRIPTION_KEY", "your subscription key")
2323

2424
async def get_country_code_async():
2525
# [START get_country_code_async]

sdk/maps/azure-maps-geolocation/samples/sample_authentication.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def authentication_maps_service_client_with_subscription_key_credential():
2929
from azure.core.credentials import AzureKeyCredential
3030
from azure.maps.geolocation import MapsGeolocationClient
3131

32-
subscription_key = os.getenv("AZURE_SUBSCRIPTION_KEY") or "your subscription key"
32+
subscription_key = os.getenv("AZURE_SUBSCRIPTION_KEY", "your subscription key")
3333

3434
maps_geolocation_client = MapsGeolocationClient(credential=AzureKeyCredential(subscription_key))
3535
# [END create_maps_geolocation_service_client_with_key]

sdk/maps/azure-maps-geolocation/samples/sample_get_country_code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
import os
2121

22-
subscription_key = os.getenv("AZURE_SUBSCRIPTION_KEY") or "your subscription key"
22+
subscription_key = os.getenv("AZURE_SUBSCRIPTION_KEY", "your subscription key")
2323

2424
def get_country_code():
2525
# [START get_country_code]

sdk/maps/azure-maps-render/azure/maps/render/_render_client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
from azure.core.credentials import AzureKeyCredential, TokenCredential
1111
from azure.core.polling import LROPoller
1212
from ._base_client import MapsRenderClientBase
13+
from ._generated.models import Copyright
1314

1415
from .models import (
1516
LatLon,
1617
BoundingBox,
1718
TilesetID,
18-
Copyright,
1919
MapTileset,
2020
CopyrightCaption,
2121
RasterTileFormat,
@@ -212,7 +212,7 @@ def get_map_attribution(
212212
:dedent: 4
213213
:caption: Return map copyright attribution information for a section of a tileset.
214214
"""
215-
bounds=[
215+
bounds_list = [
216216
bounds.south,
217217
bounds.west,
218218
bounds.north,
@@ -222,7 +222,7 @@ def get_map_attribution(
222222
return self._render_client.get_map_attribution(
223223
tileset_id=tileset_id,
224224
zoom=zoom,
225-
bounds=bounds,
225+
bounds=bounds_list,
226226
**kwargs
227227
)
228228

@@ -442,8 +442,8 @@ def get_copyright_from_bounding_box(
442442
_include_text=kwargs.pop("include_text", True)
443443

444444
return self._render_client.get_copyright_from_bounding_box(
445-
south_west=(bounding_box.south,bounding_box.west),
446-
north_east=(bounding_box.north,bounding_box.east),
445+
south_west=[bounding_box.south,bounding_box.west],
446+
north_east=[bounding_box.north,bounding_box.east],
447447
include_text= "yes" if _include_text else "no",
448448
**kwargs
449449
)

sdk/maps/azure-maps-render/azure/maps/render/aio/_render_client_async.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
from azure.core.credentials_async import AsyncTokenCredential
1313

1414
from ._base_client_async import AsyncMapsRenderClientBase
15+
from .._generated.models import Copyright
1516

1617
from ..models import (
1718
LatLon,
1819
BoundingBox,
1920
TilesetID,
20-
Copyright,
2121
MapTileset,
2222
MapAttribution,
2323
CopyrightCaption,
@@ -216,7 +216,7 @@ async def get_map_attribution(
216216
:dedent: 4
217217
:caption: Return map copyright attribution information for a section of a tileset.
218218
"""
219-
bounds=[
219+
bounds_list = [
220220
bounds.south,
221221
bounds.west,
222222
bounds.north,
@@ -226,7 +226,7 @@ async def get_map_attribution(
226226
async_result = await self._render_client.get_map_attribution(
227227
tileset_id=tileset_id,
228228
zoom=zoom,
229-
bounds=bounds,
229+
bounds=bounds_list,
230230
**kwargs
231231
)
232232
return async_result
@@ -443,13 +443,15 @@ async def get_copyright_from_bounding_box(
443443
"""
444444
_include_text=kwargs.pop("include_text", True)
445445

446-
return await self._render_client.get_copyright_from_bounding_box(
446+
result = await self._render_client.get_copyright_from_bounding_box(
447447
include_text= "yes" if _include_text else "no",
448-
south_west=(bounding_box.south,bounding_box.west),
449-
north_east=(bounding_box.north,bounding_box.east),
448+
south_west=[bounding_box.south,bounding_box.west],
449+
north_east=[bounding_box.north,bounding_box.east],
450450
**kwargs
451451
)
452452

453+
return result
454+
453455
@distributed_trace_async
454456
async def get_copyright_for_tile(
455457
self,
@@ -494,14 +496,16 @@ async def get_copyright_for_tile(
494496

495497
_include_text=kwargs.pop("include_text", True)
496498

497-
return await self._render_client.get_copyright_for_tile(
499+
result = await self._render_client.get_copyright_for_tile(
498500
z=z,
499501
x=x,
500502
y=y,
501503
include_text= "yes" if _include_text else "no",
502504
**kwargs
503505
)
504506

507+
return result
508+
505509
@distributed_trace_async
506510
async def get_copyright_for_world(
507511
self,
@@ -532,7 +536,9 @@ async def get_copyright_for_world(
532536
"""
533537
_include_text=kwargs.pop("include_text", True)
534538

535-
return await self._render_client.get_copyright_for_world(
539+
result = await self._render_client.get_copyright_for_world(
536540
include_text= "yes" if _include_text else "no",
537541
**kwargs
538542
)
543+
544+
return result

sdk/maps/azure-maps-render/azure/maps/render/models/_models.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# ------------------------------------
55

66
# pylint: disable=unused-import,ungrouped-imports,super-init-not-called, C0302, C0203
7-
from typing import NamedTuple, Any
7+
from typing import NamedTuple, Any, Optional
88
from .._generated.models import (
99
MapAttribution,
1010
Copyright as GenCopyright,
@@ -168,23 +168,23 @@ class ImagePathStyle(object):
168168
169169
:keyword path_positions:
170170
The list of point coordinate on the path.
171-
:paramtype path_positions: LatLon
171+
:paramtype path_positions: Optional[LatLon]
172172
:keyword line_color:
173173
Line color of the path, including line opacity information.
174-
:paramtype line_color: str
174+
:paramtype line_color: Optional[str]
175175
:keyword fill_color:
176176
Fill color of the path, including line opacity information.
177-
:paramtype fill_color: str
177+
:paramtype fill_color: Optional[str]
178178
:keyword line_width_in_pixels:
179179
Line width of the path in pixels.
180180
:paramtype line_width_in_pixels: int
181181
:keyword circle_radius_in_meters:
182182
Circle radius in meters.
183183
:paramtype circle_radius_in_meters: int
184184
"""
185-
path_positions: LatLon = None
186-
line_color: str = None
187-
fill_color: str = None
185+
path_positions: Optional[LatLon] = None
186+
line_color: Optional[str] = None
187+
fill_color: Optional[str] = None
188188
line_width_in_pixels: int = 0
189189
circle_radius_in_meters: int = 0
190190

@@ -193,29 +193,29 @@ class ImagePushpinStyle(object):
193193
194194
:keyword pushpin_positions:
195195
The list of Pushpin coordinate on the map.
196-
:paramtype path_positions: LatLon
196+
:paramtype path_positions: Optional[LatLon]
197197
:keyword pushpin_anchor_shift_in_pixels:
198198
To override the anchor location of the pin image,
199199
user can designate how to shift or move the anchor location by pixels
200200
:paramtype pushpin_anchor_shift_in_pixels: int
201201
:keyword pushpin_color:
202202
Pushpin color including opacity information.
203-
:paramtype pushpin_color: str
203+
:paramtype pushpin_color: Optional[str]
204204
:keyword pushpin_scale_ratio:
205205
Pushpin scale ratio. Value should greater than zero. A value of 1 is the standard scale.
206206
Values larger than 1 will make the pins larger, and values smaller than 1 will make them smaller.
207207
:paramtype pushpin_scale_ratio: float
208208
:keyword custom_pushpin_image_uri:
209209
Custom pushpin image, can only be 'ref="Uri"' format.
210-
:paramtype custom_pushpin_image_uri: str
210+
:paramtype custom_pushpin_image_uri: Optional[str]
211211
:keyword label_anchor_shift_in_pixels:
212212
The anchor location of label for built-in pushpins is at the top center of custom pushpins.
213213
To override the anchor location of the pin image,
214214
user can designate how to shift or move the anchor location by pixels
215-
:paramtype label_anchor_shift_in_pixels: LatLon
215+
:paramtype label_anchor_shift_in_pixels: Optional[LatLon]
216216
:keyword label_color:
217217
Label color information. Opacity value other than 1 be ignored.
218-
:paramtype label_color: str
218+
:paramtype label_color: Optional[str]
219219
:keyword label_scale_ratio:
220220
Label scale ratio. Should greater than 0. A value of 1 is the standard scale.
221221
Values larger than 1 will make the label larger.
@@ -226,12 +226,12 @@ class ImagePushpinStyle(object):
226226
Value can be -360 to 360.
227227
:paramtype rotation_in_degrees: int
228228
"""
229-
pushpin_positions: LatLon = None
229+
pushpin_positions: Optional[LatLon] = None
230230
pushpin_anchor_shift_in_pixels: int = 0
231-
pushpin_color: str = None
231+
pushpin_color: Optional[str] = None
232232
pushpin_scale_ratio: float = 0.0
233-
custom_pushpin_image_uri: str = None
234-
label_anchor_shift_in_pixels: LatLon = None
235-
label_color: str = None
233+
custom_pushpin_image_uri: Optional[str] = None
234+
label_anchor_shift_in_pixels: Optional[LatLon] = None
235+
label_color: Optional[str] = None
236236
label_scale_ratio: float = 0.0
237237
rotation_in_degrees: int = 0
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
[tool.azure-sdk-build]
22
pyright = false
3-
type_check_samples = false
43
verifytypes = false
54
ci_enabled = false
65
strict_sphinx = true

sdk/maps/azure-maps-render/samples/async_samples/sample_authentication_async.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ async def authentication_maps_service_client_with_subscription_key_credential_as
3131
from azure.core.credentials import AzureKeyCredential
3232
from azure.maps.render.aio import MapsRenderClient
3333

34-
subscription_key = os.getenv("AZURE_SUBSCRIPTION_KEY")
34+
subscription_key = os.getenv("AZURE_SUBSCRIPTION_KEY", "your subscription key")
3535

3636
maps_render_client = MapsRenderClient(credential=AzureKeyCredential(subscription_key))
3737
# [END create_maps_render_service_client_with_key_async]
@@ -51,7 +51,7 @@ async def authentication_maps_service_client_with_aad_credential_async():
5151
from azure.maps.render.aio import MapsRenderClient
5252

5353
credential = DefaultAzureCredential()
54-
maps_client_id = os.getenv("AZURE_MAPS_CLIENT_ID")
54+
maps_client_id = os.getenv("AZURE_MAPS_CLIENT_ID", "your client id")
5555

5656
maps_render_client = MapsRenderClient(client_id=maps_client_id, credential=credential)
5757
# [END create_maps_render_service_client_with_aad_async]

sdk/maps/azure-maps-render/samples/async_samples/sample_get_copyright_caption_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import asyncio
2222
import os
2323

24-
subscription_key = os.getenv("AZURE_SUBSCRIPTION_KEY")
24+
subscription_key = os.getenv("AZURE_SUBSCRIPTION_KEY", "your subscription key")
2525

2626
async def get_copyright_caption_async():
2727
# [START get_copyright_caption_async]

0 commit comments

Comments
 (0)