Skip to content

Commit 0d79e57

Browse files
committed
add
1 parent 52d3d4d commit 0d79e57

5 files changed

Lines changed: 33 additions & 13 deletions

File tree

tools/azure-sdk-tools/linting_tools/lint_test_bench/pylint_agent.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def get_test_cases():
5656
"""
5757
try:
5858
test_cases = []
59-
test_files_dir = Path(__file__).parent / 'test_files_without_comment'
59+
test_files_dir = Path(__file__).parent / 'test_files'
6060

6161
# Create test_files directory if it doesn't exist
6262
test_files_dir.mkdir(exist_ok=True)
@@ -231,6 +231,7 @@ def run_pylint(file_path: str, logger) -> dict:
231231
file_path = Path(__file__).parent / 'test_files' / test_case['name']
232232
# file_path = Path(__file__).parent / 'test_files_without_comment' / test_case['name']
233233

234+
print(f"Processing file: {file_path}")
234235

235236
# Run pylint on both original file
236237
logger.debug("Running pylint on original file...")
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License. See License.txt in the project root for license information.
3+
# --------------------------------------------------------------------------------------------
4+
5+
# This code violates missing-client-constructor-parameter-kwargs
6+
class ClassNameClient():
7+
def __init__(self, credential: str, *, api_version:str = "2018") -> None:
8+
"""
9+
:param credential: The credential to use for authentication.
10+
:type credential: str
11+
:keyword api_version: The API version to use.
12+
:paramtype api_version: str
13+
"""
14+
self.credential: str = credential
15+
self.api_version: str = api_version
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
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-
# This code violates missing-client-constructor-parameter-credential and missing-client-constructor-parameter-kwargs
4+
# This code violates missing-client-constructor-parameter-credential
55
class ClassNameClient():
6-
def __init__(self, *, api_version:str = "2018") -> None:
6+
def __init__(self, *, api_version:str = "2018", **kwargs) -> None:
77
"""
88
:keyword eight: The eighth parameter.
99
:paramtype eight: str
1010
:keyword api_version: The API version to use.
1111
:paramtype api_version: str
1212
"""
1313
self.api_version: str = api_version
14+
self.eight: str = kwargs.get("eight")
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
# --------------------------------------------------------------------------------------------
5+
from typing import List
6+
# This code violates client-method-missing-tracing-decoration
7+
class Some2Client():
8+
def get_thing(self) -> List[str]:
9+
return []

tools/azure-sdk-tools/linting_tools/lint_test_bench/test_files/test_lro_poller.py renamed to tools/azure-sdk-tools/linting_tools/lint_test_bench/test_files/test_lro_poller_uses_polling.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,16 @@
66
from azure.core.polling import LROPoller
77
from azure.core.tracing.decorator import distributed_trace
88

9-
# This code violates client-lro-methods-use-polling and client-method-missing-tracing-decoration
9+
# This code violates client-lro-methods-use-polling
1010

1111
class Some1Client():
12+
@distributed_trace
1213
def begin_thing(self, **kwargs) -> LROPoller:
1314
return LROPoller(self, kwargs.get("some_key"), kwargs.get("some_other_key"), kwargs.get("some_third_key"))
1415

1516
@distributed_trace
16-
def begin_thing2(self, **kwargs) -> LROPoller:
17-
return LROPoller(self, kwargs.get("some_key"), kwargs.get("some_other_key"), kwargs.get("some_third_key"))
17+
def begin_thing2(self, **kwargs) -> List:
18+
return []
1819

1920

20-
class Some2Client():
21-
def begin_thing(self) -> List[str]:
22-
return []
2321

24-
def begin_thing2(self) -> Dict[str, Any]:
25-
return {}
26-
def poller(self, **kwargs) -> LROPoller:
27-
return LROPoller(self, kwargs.get("some_key"), kwargs.get("some_other_key"), kwargs.get("some_third_key"))

0 commit comments

Comments
 (0)