Skip to content

Commit 9a0f909

Browse files
committed
Linter ai
1 parent a860451 commit 9a0f909

File tree

10 files changed

+33
-50
lines changed

10 files changed

+33
-50
lines changed

src/arcdata/arcdata/azext_arcdata/core/exceptions.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55
# ------------------------------------------------------------------------------
66

77
from knack.cli import CLIError
8-
from requests.exceptions import HTTPError
98

109

1110
class ClusterLogError(CLIError):
1211
"""All errors related to log collection calls."""
13-
14-
pass

src/arcdata/arcdata/azext_arcdata/core/http_codes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
__all__ = ["HTTPCodes"]
88

99

10-
class HTTPCodes(object):
10+
class HTTPCodes:
1111
"""
1212
Defines the HTTP status codes.
1313
NOTE: Add more when needed.

src/arcdata/arcdata/azext_arcdata/core/identity.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# ------------------------------------------------------------------------------
66

77
from knack.log import get_logger
8+
from typing import Any, Optional
89

910
import os
1011
import abc
@@ -32,19 +33,19 @@ def __init__(self, *args, **kwargs):
3233

3334
@abc.abstractmethod
3435
def acquire_token(self, *scopes, **kwargs):
35-
# type: (*str, **Any) -> Optional[AccessToken]
36+
# type: (*str, **Any) -> Optional[Any]
3637
"""
3738
Attempt to acquire an access token from a cache or by redeeming a
3839
refresh token
3940
"""
4041

4142
@abc.abstractmethod
4243
def request_token(self, *scopes, **kwargs):
43-
# type: (*str, **Any) -> AccessToken
44+
# type: (*str, **Any) -> Any
4445
"""Request an access token"""
4546

4647
def should_refresh(self, token):
47-
# type: (AccessToken) -> bool
48+
# type: (Any) -> bool
4849
now = int(time.time())
4950
if token.expires_on - now > BaseTokenMixin.DEFAULT_REFRESH_OFFSET:
5051
return False
@@ -56,7 +57,7 @@ def should_refresh(self, token):
5657
return True
5758

5859
def get_token(self, *scopes, **kwargs):
59-
# type: (*str, **Any) -> AccessToken
60+
# type: (*str, **Any) -> Any
6061
"""
6162
Request an access token for `scopes`.
6263
@@ -89,7 +90,7 @@ def __init__(self, scopes=None):
8990

9091
# override
9192
def get_token(self, *scopes, **kwargs):
92-
# type: (*str, **Any) -> AccessToken
93+
# type: (*str, **Any) -> Any
9394
"""
9495
Request an access token for `scopes`.
9596
"""
@@ -113,7 +114,7 @@ def get_token(self, *scopes, **kwargs):
113114

114115
# override
115116
def acquire_token(self, *scopes):
116-
# type: (*str) -> Optional[AccessToken]
117+
# type: (*str) -> Optional[Any]
117118
"""
118119
Attempt to acquire an access token from a cache or by redeeming
119120
a refresh token.
@@ -125,16 +126,13 @@ def acquire_token(self, *scopes):
125126
azure_folder = get_config_dir()
126127
ACCOUNT.load(os.path.join(azure_folder, "azureProfile.json"))
127128
p = Profile(storage=ACCOUNT)
128-
cred, subscription_id, tenant_id = p.get_login_credentials()
129+
cred, _, _ = p.get_login_credentials()
129130
scopes = ["https://management.azure.com/.default"]
130131
access_token = cred.get_token(*scopes)
131132

132133
return access_token
133134

134135
# override
135136
def request_token(self, *scopes, **kwargs):
136-
# TODO: Impl refresh logic if possible. For now we give error
137-
# to az login again
138-
return super(ArcDataCliCredential, self).request_token(
139-
*scopes, **kwargs
140-
)
137+
# TODO: Implement refresh logic if possible. For now, raise an error to prompt az login again.
138+
raise NotImplementedError("Token refresh logic not implemented. Please run 'az login' again.")

src/arcdata/arcdata/azext_arcdata/core/labels.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ def parse_labels(label_str):
2121

2222
label_key, label_value = label_kv
2323

24-
if label_key in labels.keys():
24+
if label_key in labels:
2525
raise ValueError("Duplicate label key {}".format(label_key))
26-
2726
labels[label_key.strip()] = label_value.strip()
2827

2928
return labels

src/arcdata/arcdata/azext_arcdata/core/layout.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616

1717
@add_metaclass(ABCMeta)
18-
class BaseLayout(object):
18+
class BaseLayout:
1919
def __init__(self):
2020
pass
2121

@@ -311,13 +311,13 @@ def stack(data, boxes, parent="", name="", trail="", identifiers=None):
311311
def __repr__(self):
312312
return self.render()
313313

314-
314+
class BaseLayout:
315315
# ---------------------------------------------------------------------------- #
316316
# ---------------------------------------------------------------------------- #
317317
# ---------------------------------------------------------------------------- #
318318

319319

320-
class Box(object):
320+
class Box:
321321
def __init__(self, data):
322322
self._data = data
323323
self._identifiers = (
@@ -351,10 +351,11 @@ def render(self):
351351

352352

353353
def print_formatted_text(text, end="\n"):
354-
from prompt_toolkit import print_formatted_text as pft
355-
356354
try:
355+
from prompt_toolkit import print_formatted_text as pft
357356
pft(text, end=end)
357+
except ImportError:
358+
print(text, end=end)
358359
except Exception:
359360
print(text, end=end)
360361

@@ -371,23 +372,22 @@ def indention(depth):
371372

372373
def badge(text, depth=0, end="", identifiers=None):
373374
def background(label, color):
374-
from prompt_toolkit import print_formatted_text as pft, ANSI
375-
376375
try:
376+
from prompt_toolkit import print_formatted_text as pft, ANSI
377377
style = {"green": 102, "red": 101}[color]
378378
pft(
379379
ANSI(
380380
"\x1b[97;{style}m{label}".format(style=style, label=label)
381381
),
382382
end="",
383383
)
384-
except Exception:
385-
# shim fall back for cygwin/git-bash/ect...
384+
except ImportError:
386385
from colorama import init, Back
387-
388386
init(strip=False)
389387
style = {"green": Back.GREEN, "red": Back.RED}[color]
390388
print("{}{}".format(style, label) + Back.RESET, end="")
389+
except Exception:
390+
print(label)
391391

392392
margin_left = "".ljust(indention(depth))
393393

src/arcdata/arcdata/azext_arcdata/core/output.py

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

2020

2121
@singleton
22-
class OutputStream(object):
22+
class OutputStream:
2323
__ORIGINAL_STDOUT__ = sys.stdout
2424
"""
2525
Placeholder for the original system stdout.

src/arcdata/arcdata/azext_arcdata/core/serialization.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ def sanitize_value(self, property_path, value):
2929
return value
3030

3131

32-
class Sanitizer(object):
32+
class Sanitizer:
3333
"""
3434
Object sanitizer allowing for properties to be excluded based on
3535
configurable filters
3636
"""
3737

38-
def __init__(self, filters: List[SanitizerRule] = [], *args, **kwargs):
38+
def __init__(self, filters: List[SanitizerRule] = None, *args, **kwargs):
3939
"""
4040
Initializer with additional parameters for managing serialized content
4141
@@ -46,7 +46,7 @@ def __init__(self, filters: List[SanitizerRule] = [], *args, **kwargs):
4646
"""
4747
super().__init__(*args, **kwargs)
4848
self._serializedInstances = []
49-
self._filters = filters
49+
self._filters = filters if filters is not None else []
5050

5151
def sanitize_value(self, property_path, property_value):
5252
for f in self._filters:
@@ -99,12 +99,12 @@ def sanitize(self, obj, path=""):
9999
return self.sanitize_value(path, obj)
100100

101101
@staticmethod
102-
def sanitize_object(obj, filters: List[SanitizerRule] = []):
102+
def sanitize_object(obj, filters: List[SanitizerRule] = None):
103103
"""
104104
Convenience method allowing for an object and filters to be passed in.
105105
The results will be the sanitized object
106106
"""
107-
sanitizer = Sanitizer(filters)
107+
sanitizer = Sanitizer(filters if filters is not None else [])
108108
return sanitizer.sanitize(obj)
109109

110110
@staticmethod

src/arcdata/arcdata/azext_arcdata/core/services.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def beget_service(az_cli):
7575

7676

7777
@add_metaclass(ABCMeta)
78-
class BaseServiceProxy(object):
78+
class BaseServiceProxy:
7979
def __init__(self, name):
8080
self._name = name
8181

@@ -110,6 +110,7 @@ def get_crd_dict():
110110
}
111111

112112
@staticmethod
113+
113114
def get_spec_file_dict():
114115
import azext_arcdata.vendored_sdks.kubernetes_sdk.dc.constants as dc_constants
115116

@@ -228,7 +229,7 @@ def get_config(self, command_value_object: tuple):
228229

229230

230231
@add_metaclass(ABCMeta)
231-
class ArmMixin(object):
232+
class ArmMixin:
232233
@staticmethod
233234
def get_azure_credentials(az_cli):
234235
from azure.common.credentials import get_cli_profile
@@ -277,7 +278,7 @@ def acquire_arm_client(az_cli):
277278

278279

279280
@add_metaclass(ABCMeta)
280-
class KubernetesMixin(object):
281+
class KubernetesMixin:
281282
def __init__(self):
282283
self.apply_context()
283284

src/arcdata/arcdata/azext_arcdata/core/util.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
)
2222
from knack.log import get_logger
2323
from knack.cli import CLIError
24+
2425
from kubernetes import config as kconfig
2526
from kubernetes.config.config_exception import ConfigException
2627
from jsonpatch import JsonPatch

src/arcdata/arcdata/azext_arcdata/sqlmi/custom.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -607,22 +607,15 @@ def arc_sql_mi_edit(
607607
license_type=None,
608608
tier=None,
609609
nowait=False,
610-
dev=None,
611610
labels=None,
612611
annotations=None,
613612
service_labels=None,
614613
service_annotations=None,
615614
agent_enabled=None,
616615
trace_flags=None,
617-
time_zone=None,
618616
use_k8s=None,
619617
retention_days=None,
620-
# -- direct --
621618
resource_group=None,
622-
location=None,
623-
custom_location=None,
624-
tag_name=None,
625-
tag_value=None,
626619
):
627620
"""
628621
Deprecated, use update over edit.
@@ -632,7 +625,6 @@ def arc_sql_mi_edit(
632625
client,
633626
name,
634627
path=path,
635-
time_zone=time_zone,
636628
cores_limit=cores_limit,
637629
cores_request=cores_request,
638630
memory_limit=memory_limit,
@@ -675,7 +667,6 @@ def arc_sql_mi_update(
675667
readable_secondaries=None,
676668
sync_secondary_to_commit=None,
677669
path=None,
678-
time_zone=None,
679670
cores_limit=None,
680671
cores_request=None,
681672
memory_limit=None,
@@ -694,15 +685,11 @@ def arc_sql_mi_update(
694685
certificate_private_key_file=None,
695686
service_certificate_secret=None,
696687
preferred_primary_replica=None,
697-
# -- indirect --
698688
use_k8s=None,
699689
namespace=None,
700-
# -- direct --
701690
resource_group=None,
702-
# -- Active Directory --
703691
keytab_secret=None,
704692
ad_encryption_types=None,
705-
# -- Transparent Data Encryption --
706693
tde_mode=None,
707694
tde_protector_secret=None,
708695
tde_protector_public_key_file=None,

0 commit comments

Comments
 (0)