Skip to content

Commit 61673f5

Browse files
author
Yalin Li
authored
[Tables] Fix mypy errors (#39170)
1 parent f0e77dc commit 61673f5

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

sdk/tables/azure-data-tables/azure/data/tables/_authentication.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,15 @@ def on_challenge(self, request: PipelineRequest, response: PipelineResponse) ->
209209
return False
210210

211211
if self._discover_tenant:
212-
self.authorize_request(request, scope, tenant_id=challenge.tenant_id)
212+
if isinstance(scope, str):
213+
self.authorize_request(request, scope, tenant_id=challenge.tenant_id)
214+
else:
215+
self.authorize_request(request, *scope, tenant_id=challenge.tenant_id)
213216
else:
214-
self.authorize_request(request, scope)
217+
if isinstance(scope, str):
218+
self.authorize_request(request, scope)
219+
else:
220+
self.authorize_request(request, *scope)
215221
return True
216222

217223

sdk/tables/azure-data-tables/azure/data/tables/aio/_authentication_async.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,15 @@ async def on_challenge(self, request: PipelineRequest, response: PipelineRespons
6565
return False
6666

6767
if self._discover_tenant:
68-
await self.authorize_request(request, scope, tenant_id=challenge.tenant_id)
68+
if isinstance(scope, str):
69+
await self.authorize_request(request, scope, tenant_id=challenge.tenant_id)
70+
else:
71+
await self.authorize_request(request, *scope, tenant_id=challenge.tenant_id)
6972
else:
70-
await self.authorize_request(request, scope)
73+
if isinstance(scope, str):
74+
await self.authorize_request(request, scope)
75+
else:
76+
await self.authorize_request(request, *scope)
7177
return True
7278

7379

sdk/tables/azure-data-tables/tests/test_challenge_auth.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ def get_token(*scopes, **kwargs):
249249
raise ValueError("unexpected token request")
250250

251251
credential = Mock(spec_set=["get_token"], get_token=Mock(wraps=get_token))
252-
policy = BearerTokenChallengePolicy(credential, "scope", discover_scopes=False)
252+
policy = BearerTokenChallengePolicy(credential, ["scope1", "scope2"], discover_scopes=False)
253253
pipeline = Pipeline(policies=[policy], transport=Mock(send=send))
254254
pipeline.run(http_request("GET", "https://localhost"))
255255

@@ -300,7 +300,9 @@ def get_token(*scopes, **kwargs):
300300
raise ValueError("unexpected token request")
301301

302302
credential = Mock(spec_set=["get_token"], get_token=Mock(wraps=get_token))
303-
policy = BearerTokenChallengePolicy(credential, "scope", discover_tenant=False, discover_scopes=False)
303+
policy = BearerTokenChallengePolicy(
304+
credential, ["scope1", "scope2"], discover_tenant=False, discover_scopes=False
305+
)
304306
pipeline = Pipeline(policies=[policy], transport=Mock(send=send))
305307
pipeline.run(http_request("GET", "https://localhost"))
306308

sdk/tables/azure-data-tables/tests/test_challenge_auth_async.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ async def get_token(*scopes, **kwargs):
250250
raise ValueError("unexpected token request")
251251

252252
credential = Mock(spec_set=["get_token"], get_token=Mock(wraps=get_token))
253-
policy = AsyncBearerTokenChallengePolicy(credential, "scope", discover_scopes=False)
253+
policy = AsyncBearerTokenChallengePolicy(credential, ["scope1", "scope2"], discover_scopes=False)
254254
pipeline = AsyncPipeline(policies=[policy], transport=Mock(send=send))
255255
await pipeline.run(http_request("GET", "https://localhost"))
256256

@@ -301,7 +301,9 @@ async def get_token(*scopes, **kwargs):
301301
raise ValueError("unexpected token request")
302302

303303
credential = Mock(spec_set=["get_token"], get_token=Mock(wraps=get_token))
304-
policy = AsyncBearerTokenChallengePolicy(credential, "scope", discover_tenant=False, discover_scopes=False)
304+
policy = AsyncBearerTokenChallengePolicy(
305+
credential, ["scope1", "scope2"], discover_tenant=False, discover_scopes=False
306+
)
305307
pipeline = AsyncPipeline(policies=[policy], transport=Mock(send=send))
306308
await pipeline.run(http_request("GET", "https://localhost"))
307309

0 commit comments

Comments
 (0)