Skip to content

Commit b45b85a

Browse files
committed
file updates
1 parent 7a60144 commit b45b85a

8 files changed

Lines changed: 45 additions & 38 deletions

tools/azure-sdk-tools/linting_tools/lint_test_bench/test_files/test_client_constructor_takes_credential.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# Copyright (c) Microsoft Corporation. All rights reserved.
22
# Licensed under the MIT License. See License.txt in the project root for license information.
33
# --------------------------------------------------------------------------------------------
4+
from typing import Any
45
# This code violates missing-client-constructor-parameter-credential
56
class ClassNameClient():
6-
def __init__(self, *, api_version:str = "2018", **kwargs) -> None:
7+
def __init__(self, *, api_version: str = "2018", **kwargs: Any) -> None:
78
"""
89
:keyword eight: The eighth parameter.
910
:paramtype eight: str

tools/azure-sdk-tools/linting_tools/lint_test_bench/test_files/test_client_method_missing_tracing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
class Some2Client():
99

1010
@distributed_trace_async
11-
def get_thing(self) -> List[str]:
11+
def get_thing(self, **kwargs) -> List[str]:
1212
return []

tools/azure-sdk-tools/linting_tools/lint_test_bench/test_files/test_delete_wrong_return_type.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@
99
class MyClient():
1010
@distributed_trace
1111
def delete_some_function(self, **kwargs) -> str:
12-
return kwargs.get("some_key")
12+
client = kwargs.get("some_client")
13+
client.delete()
14+
# Do something with the key
15+
return self

tools/azure-sdk-tools/linting_tools/lint_test_bench/test_files/test_exception_log.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,20 @@
66

77
# This code violates do-not-log-exceptions-if-not-debug
88

9-
try:
10-
a = "this is doing something here"
11-
except TypeError as e:
12-
logging.info(
13-
"This is a TypeError: %s",
14-
e,
15-
)
9+
def add(a, b):
10+
"""
11+
Add two numbers together.
12+
:param a: The first number.
13+
:param b: The second number.
14+
:return: The sum of the two numbers.
15+
"""
16+
logging.debug("Adding %s and %s", a, b)
17+
try:
18+
return a + b
19+
except TypeError as e:
20+
logging.info(
21+
"This is a TypeError: %s",
22+
e,
23+
)
1624

1725

tools/azure-sdk-tools/linting_tools/lint_test_bench/test_files/test_exception_raise_log.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,19 @@
66

77
# This code violates do-not-log-raised-errors
88

9-
try:
10-
a = "this is doing something here"
11-
a.get("this")
12-
except TypeError as e:
13-
logging.debug(
14-
"This is a TypeError: %s",
15-
e,
16-
)
17-
raise e
18-
9+
def add(a, b):
10+
"""
11+
Add two numbers together.
12+
:param a: The first number.
13+
:param b: The second number.
14+
:return: The sum of the two numbers.
15+
"""
16+
logging.debug("Adding %s and %s", a, b)
17+
try:
18+
return a + b
19+
except TypeError as e:
20+
logging.debug(
21+
"This is a TypeError: %s",
22+
e,
23+
)
24+
raise e

tools/azure-sdk-tools/linting_tools/lint_test_bench/test_files/test_import_errors.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,11 @@
22
# Copyright (c) Microsoft Corporation. All rights reserved.
33
# Licensed under the MIT License. See License.txt in the project root for license information.
44
# --------------------------------------------------------------------------------------------
5-
import requests
6-
import httpx
7-
import aiohttp
85
from azure.core.exceptions import raise_with_traceback
9-
# This code violates no-raise-with-traceback, networking-import-outside-azure-core-transport
6+
# This code violates no-raise-with-traceback
107

118

129
async def main():
13-
r = requests.get("http://localhost:8080/basic/string", timeout=0.1)
14-
print(r.status_code)
15-
r = httpx.get("http://localhost:8080/basic/string")
16-
print(r.status_code)
17-
async with aiohttp.ClientSession() as session:
18-
async with session.get("http://localhost:8080/basic/string") as response:
19-
print(response.status)
20-
2110
l = {}
2211
try:
2312
l["a"].append(1)

tools/azure-sdk-tools/linting_tools/lint_test_bench/test_files/test_no_typing_under_type_checking.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
from typing import Any
1111

1212

13-
def foo() -> Any:
13+
def create_number() -> Any:
1414
return 42

tools/azure-sdk-tools/linting_tools/lint_test_bench/test_files/test_non_abstract_transport.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33
# Licensed under the MIT License. See License.txt in the project root for license information.
44
# --------------------------------------------------------------------------------------------
55
from azure.core.pipeline import AsyncPipeline
6-
from azure.core.pipeline.transport import HttpRequest as PipelineTransportHttpRequest
6+
from azure.core.pipeline.transport import HttpRequest
77
from azure.core.pipeline.policies import (
88
UserAgentPolicy,
99
AsyncRedirectPolicy,
1010
)
1111
from azure.core.pipeline.transport import (
12-
AioHttpTransport,
12+
RequestsTransport,
1313
)
1414
# This code violates do-not-import-asyncio
1515

1616
async def main():
1717
port = 8080
18-
request = PipelineTransportHttpRequest("GET", "http://localhost:{}/basic/string".format(port))
19-
policies = [UserAgentPolicy("myusergant"), AsyncRedirectPolicy()]
20-
async with AsyncPipeline(AioHttpTransport(), policies=policies) as pipeline:
18+
request = HttpRequest("GET", "http://localhost:{}/basic/string".format(port))
19+
policies = [UserAgentPolicy("myuseragent"), AsyncRedirectPolicy()]
20+
async with AsyncPipeline(RequestsTransport(), policies=policies) as pipeline:
2121
response = await pipeline.run(request)
2222
print(response.http_response.status_code)

0 commit comments

Comments
 (0)