Skip to content

Commit 4060aa8

Browse files
committed
Safe lint fixes
1 parent b136c21 commit 4060aa8

17 files changed

+53
-84
lines changed

azure-kusto-data/azure/kusto/data/aio/streaming_response.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from ijson import IncompleteJSONError
66

77
from azure.kusto.data._models import WellKnownDataSet
8-
from azure.kusto.data.exceptions import KustoTokenParsingError, KustoUnsupportedApiError, KustoApiError, KustoMultiApiError
8+
from azure.kusto.data.exceptions import KustoTokenParsingError, KustoUnsupportedApiError, KustoMultiApiError
99
from azure.kusto.data.streaming_response import JsonTokenType, FrameType, JsonToken
1010

1111

azure-kusto-data/azure/kusto/data/client_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def _handle_http_error(
116116
raise KustoThrottlingError("The request was throttled by the server.", response) from exception
117117

118118
if status == 401:
119-
raise KustoServiceError(f"401. Missing adequate access rights.", response) from exception
119+
raise KustoServiceError("401. Missing adequate access rights.", response) from exception
120120

121121
if payload:
122122
message = f"An error occurred while trying to ingest: Status: {status}, Reason: {response.reason}, Text: {response_text}."

azure-kusto-data/azure/kusto/data/kusto_trusted_endpoints.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import copy
2-
import json
3-
from pathlib import Path
42
from typing import List, Dict
53
from urllib.parse import urlparse
64

azure-kusto-data/azure/kusto/data/security.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from urllib.parse import urlparse
55

66
from ._token_providers import (
7-
TokenProviderBase,
87
BasicTokenProvider,
98
CallbackTokenProvider,
109
MsiTokenProvider,

azure-kusto-data/azure/kusto/data/streaming_response.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from ijson import IncompleteJSONError
66

77
from azure.kusto.data._models import WellKnownDataSet
8-
from azure.kusto.data.exceptions import KustoServiceError, KustoTokenParsingError, KustoUnsupportedApiError, KustoApiError, KustoMultiApiError
8+
from azure.kusto.data.exceptions import KustoTokenParsingError, KustoUnsupportedApiError, KustoMultiApiError
99

1010

1111
class JsonTokenType(Enum):

azure-kusto-data/tests/aio/test_kusto_client.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@
1111
from azure.kusto.data.client_request_properties import ClientRequestProperties
1212
from azure.kusto.data.exceptions import KustoClosedError, KustoMultiApiError, KustoNetworkError
1313
from azure.kusto.data.helpers import dataframe_from_result_table
14-
from ..kusto_client_common import KustoClientTestsMixin, mocked_requests_post, proxy_kcsb
14+
from ..kusto_client_common import KustoClientTestsMixin, mocked_requests_post
1515
from ..test_kusto_client import TestKustoClient as KustoClientTestsSync
1616

1717
PANDAS = False
1818
try:
19-
import pandas
2019

2120
PANDAS = True
2221
except:

azure-kusto-data/tests/conftest.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@pytest.fixture(
2+
params=[
3+
"user_password",
4+
"application_key",
5+
"application_token",
6+
"device",
7+
"user_token",
8+
"managed_identity",
9+
"token_provider",
10+
"async_token_provider",
11+
"az_cli",
12+
"interactive_login",
13+
]
14+
)
15+
def proxy_kcsb(request) -> Tuple[KustoConnectionStringBuilder, bool]:
16+
cluster = KustoClientTestsMixin.HOST
17+
user = "test2"
18+
password = "Pa$$w0rd2"
19+
authority_id = "13456"
20+
uuid = "11111111-1111-1111-1111-111111111111"
21+
key = "key of application"
22+
token = "The app hardest token ever"
23+
24+
return {
25+
"user_password": (KustoConnectionStringBuilder.with_aad_user_password_authentication(cluster, user, password, authority_id), True),
26+
"application_key": (KustoConnectionStringBuilder.with_aad_application_key_authentication(cluster, uuid, key, "microsoft.com"), True),
27+
"application_token": (KustoConnectionStringBuilder.with_aad_application_token_authentication(cluster, application_token=token), False),
28+
"device": (KustoConnectionStringBuilder.with_aad_device_authentication(cluster), True),
29+
"user_token": (KustoConnectionStringBuilder.with_aad_user_token_authentication(cluster, user_token=token), False),
30+
"managed_identity": (KustoConnectionStringBuilder.with_aad_managed_service_identity_authentication(cluster), False),
31+
"token_provider": (KustoConnectionStringBuilder.with_token_provider(cluster, lambda x: x), False),
32+
"async_token_provider": (KustoConnectionStringBuilder.with_async_token_provider(cluster, lambda x: x), False),
33+
"az_cli": (KustoConnectionStringBuilder.with_az_cli_authentication(cluster), True),
34+
"interactive_login": (KustoConnectionStringBuilder.with_interactive_login(cluster), True),
35+
}[request.param]

azure-kusto-data/tests/kusto_client_common.py

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@
55
import uuid
66
from datetime import datetime, timedelta
77
from io import BytesIO
8-
from typing import Optional, Any, Dict, Union, Iterator, Tuple
8+
from typing import Optional, Any, Dict, Union, Iterator
99

10-
import pytest
1110
from dateutil.tz import UTC
1211
from requests import HTTPError
1312

14-
from azure.kusto.data import KustoConnectionStringBuilder
1513
from azure.kusto.data._models import KustoResultRow, KustoResultTable, KustoStreamingResultTable
1614
from azure.kusto.data.response import WellKnownDataSet, KustoStreamingResponseDataSet, KustoResponseDataSet
1715

@@ -135,43 +133,6 @@ def raise_for_status(self):
135133
return MockResponse(None, 404, url)
136134

137135

138-
@pytest.fixture(
139-
params=[
140-
"user_password",
141-
"application_key",
142-
"application_token",
143-
"device",
144-
"user_token",
145-
"managed_identity",
146-
"token_provider",
147-
"async_token_provider",
148-
"az_cli",
149-
"interactive_login",
150-
]
151-
)
152-
def proxy_kcsb(request) -> Tuple[KustoConnectionStringBuilder, bool]:
153-
cluster = KustoClientTestsMixin.HOST
154-
user = "test2"
155-
password = "Pa$$w0rd2"
156-
authority_id = "13456"
157-
uuid = "11111111-1111-1111-1111-111111111111"
158-
key = "key of application"
159-
token = "The app hardest token ever"
160-
161-
return {
162-
"user_password": (KustoConnectionStringBuilder.with_aad_user_password_authentication(cluster, user, password, authority_id), True),
163-
"application_key": (KustoConnectionStringBuilder.with_aad_application_key_authentication(cluster, uuid, key, "microsoft.com"), True),
164-
"application_token": (KustoConnectionStringBuilder.with_aad_application_token_authentication(cluster, application_token=token), False),
165-
"device": (KustoConnectionStringBuilder.with_aad_device_authentication(cluster), True),
166-
"user_token": (KustoConnectionStringBuilder.with_aad_user_token_authentication(cluster, user_token=token), False),
167-
"managed_identity": (KustoConnectionStringBuilder.with_aad_managed_service_identity_authentication(cluster), False),
168-
"token_provider": (KustoConnectionStringBuilder.with_token_provider(cluster, lambda x: x), False),
169-
"async_token_provider": (KustoConnectionStringBuilder.with_async_token_provider(cluster, lambda x: x), False),
170-
"az_cli": (KustoConnectionStringBuilder.with_az_cli_authentication(cluster), True),
171-
"interactive_login": (KustoConnectionStringBuilder.with_interactive_login(cluster), True),
172-
}[request.param]
173-
174-
175136
DIGIT_WORDS = [str("Zero"), str("One"), str("Two"), str("Three"), str("Four"), str("Five"), str("Six"), str("Seven"), str("Eight"), str("Nine"), str("ten")]
176137

177138
SyncResponseSet = Union[KustoStreamingResponseDataSet, KustoResponseDataSet]

azure-kusto-data/tests/test_kusto_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from azure.kusto.data.exceptions import KustoClosedError, KustoMultiApiError, KustoNetworkError, KustoServiceError
1212
from azure.kusto.data.helpers import dataframe_from_result_table
1313
from azure.kusto.data.response import KustoStreamingResponseDataSet
14-
from tests.kusto_client_common import KustoClientTestsMixin, mocked_requests_post, get_response_first_primary_result, get_table_first_row, proxy_kcsb
14+
from tests.kusto_client_common import KustoClientTestsMixin, mocked_requests_post, get_response_first_primary_result, get_table_first_row
1515

1616

1717
@pytest.fixture(params=[KustoClient.execute_query, KustoClient.execute_streaming_query])
@@ -130,7 +130,7 @@ def test_dynamic(self, mock_post, method):
130130
def test_json_401(self, mock_post, method):
131131
"""Tests 401 permission errors."""
132132
with KustoClient(self.HOST) as client:
133-
with pytest.raises(KustoServiceError, match=f"401. Missing adequate access rights."):
133+
with pytest.raises(KustoServiceError, match="401. Missing adequate access rights."):
134134
query = "execute_401"
135135
response = method.__call__(client, "PythonTest", query)
136136
get_response_first_primary_result(response)

azure-kusto-data/tests/test_kusto_connection_string_builder.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ def test_add_msi(self):
271271
exception_occurred = False
272272
try:
273273
fault = KustoConnectionStringBuilder.with_aad_managed_service_identity_authentication("localhost", client_id=client_guid, object_id=object_guid)
274-
except ValueError as e:
274+
except ValueError:
275275
exception_occurred = True
276276
finally:
277277
assert exception_occurred
@@ -291,7 +291,7 @@ def test_add_token_provider(self):
291291
exception_occurred = False
292292
try:
293293
kscb = KustoConnectionStringBuilder.with_token_provider("localhost", caller_token)
294-
except AssertionError as ex:
294+
except AssertionError:
295295
exception_occurred = True
296296
finally:
297297
assert exception_occurred
@@ -310,7 +310,7 @@ async def async_token_provider():
310310
exception_occurred = False
311311
try:
312312
kscb = KustoConnectionStringBuilder.with_async_token_provider("localhost", caller_token)
313-
except AssertionError as ex:
313+
except AssertionError:
314314
exception_occurred = True
315315
finally:
316316
assert exception_occurred

0 commit comments

Comments
 (0)