Skip to content

Commit 9d5c86d

Browse files
committed
Make line length 120 characters
1 parent cc86d13 commit 9d5c86d

File tree

5 files changed

+26
-83
lines changed

5 files changed

+26
-83
lines changed

docs/conf.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,7 @@
9898
# so a file named "default.css" will overwrite the builtin "default.css".
9999
# html_static_path = ['_static']
100100

101-
html_sidebars = {
102-
"**": ["globaltoc.html", "relations.html", "sourcelink.html", "searchbox.html"]
103-
}
101+
html_sidebars = {"**": ["globaltoc.html", "relations.html", "sourcelink.html", "searchbox.html"]}
104102

105103
# -- Options for HTMLHelp output ------------------------------------------
106104

pyixapi/core/api.py

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -67,27 +67,17 @@ def __init__(
6767
self.facilities = Endpoint(self, "facilities", model=Facility)
6868
self.ips = Endpoint(self, "ips", model=IP)
6969
self.macs = Endpoint(self, "macs", model=MAC)
70-
self.network_feature_configs = Endpoint(
71-
self, "network-feature-configs", model=NetworkFeatureConfig
72-
)
70+
self.network_feature_configs = Endpoint(self, "network-feature-configs", model=NetworkFeatureConfig)
7371
self.network_features = Endpoint(self, "network-features", model=NetworkFeature)
74-
self.network_service_configs = Endpoint(
75-
self, "network-service-configs", model=NetworkServiceConfig
76-
)
72+
self.network_service_configs = Endpoint(self, "network-service-configs", model=NetworkServiceConfig)
7773
self.network_services = Endpoint(self, "network-services", model=NetworkService)
7874
self.pops = Endpoint(self, "pops", model=PoP)
7975
# Version 2+
80-
self.member_joining_rules = Endpoint(
81-
self, "member-joining-rules", model=MemberJoiningRule
82-
)
76+
self.member_joining_rules = Endpoint(self, "member-joining-rules", model=MemberJoiningRule)
8377
self.metro_areas = Endpoint(self, "metro-areas", model=MetroArea)
84-
self.metro_area_networks = Endpoint(
85-
self, "metro-area-networks", model=MetroAreaNetwork
86-
)
78+
self.metro_area_networks = Endpoint(self, "metro-area-networks", model=MetroAreaNetwork)
8779
self.ports = Endpoint(self, "ports", model=Port)
88-
self.port_reservations = Endpoint(
89-
self, "port-reservations", model=PortReservation
90-
)
80+
self.port_reservations = Endpoint(self, "port-reservations", model=PortReservation)
9181
self.roles = Endpoint(self, "roles", model=Role)
9282
self.role_assignments = Endpoint(self, "role-assignments", model=RoleAssignment)
9383

@@ -96,15 +86,11 @@ def version(self) -> int:
9686
"""
9787
Get the API version of IX-API.
9888
"""
99-
return Request(
100-
base=self.url, token=self.access_token, http_session=self.http_session
101-
).get_version()
89+
return Request(base=self.url, token=self.access_token, http_session=self.http_session).get_version()
10290

10391
@property
10492
def accounts(self) -> Endpoint:
105-
return Endpoint(
106-
self, "customers" if self.version == 1 else "accounts", model=Account
107-
)
93+
return Endpoint(self, "customers" if self.version == 1 else "accounts", model=Account)
10894

10995
@property
11096
def product_offerings(self) -> Endpoint:
@@ -132,9 +118,9 @@ def authenticate(self) -> Record:
132118
if self.refresh_token and not self.refresh_token.is_expired:
133119
return self.refresh_authentication()
134120

135-
r = Request(
136-
cat(self.url, "auth", "token"), http_session=self.http_session
137-
).post(data={"api_key": self.key, "api_secret": self.secret})
121+
r = Request(cat(self.url, "auth", "token"), http_session=self.http_session).post(
122+
data={"api_key": self.key, "api_secret": self.secret}
123+
)
138124

139125
self.access_token = Token.from_jwt(r["access_token"])
140126
self.refresh_token = Token.from_jwt(r["refresh_token"])
@@ -165,6 +151,4 @@ def health(self) -> dict[str, Any]:
165151
if self.version == 1:
166152
return {}
167153

168-
return Request(
169-
base=self.url, token=self.access_token, http_session=self.http_session
170-
).get_health()
154+
return Request(base=self.url, token=self.access_token, http_session=self.http_session).get_health()

pyixapi/core/query.py

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,13 @@ def __init__(self, r) -> None:
1616
if r.status_code == HTTPStatus.NOT_FOUND:
1717
self.message = f"The requested url: {r.url} could not be found."
1818
elif r.status_code == HTTPStatus.UNAUTHORIZED:
19-
self.message = (
20-
"Authentication credentials are invalid, tokens renewal required."
21-
)
19+
self.message = "Authentication credentials are invalid, tokens renewal required."
2220
else:
2321
try:
24-
self.message = (
25-
f"The request failed with code {r.status_code} "
26-
f"{r.reason}: {r.json()}"
27-
)
22+
self.message = f"The request failed with code {r.status_code} " f"{r.reason}: {r.json()}"
2823
except ValueError:
2924
self.message = (
30-
f"The request failed with code {r.status_code} "
31-
f"{r.reason} but details were not found as JSON."
25+
f"The request failed with code {r.status_code} " f"{r.reason} but details were not found as JSON."
3226
)
3327

3428
super().__init__(r)
@@ -50,9 +44,7 @@ def __init__(self, req) -> None:
5044
super().__init__(req)
5145

5246
self.req = req
53-
self.error = (
54-
"The server returned invalid (non-JSON) data. Maybe not an IX-API server?"
55-
)
47+
self.error = "The server returned invalid (non-JSON) data. Maybe not an IX-API server?"
5648

5749
def __str__(self) -> str:
5850
return self.error
@@ -71,9 +63,7 @@ class Request:
7163
dict.
7264
"""
7365

74-
def __init__(
75-
self, base, http_session, filters=None, key=None, token=None, user_agent=None
76-
) -> None:
66+
def __init__(self, base, http_session, filters=None, key=None, token=None, user_agent=None) -> None:
7767
self.base = base
7868
self.filters = filters or None
7969
self.key = key
@@ -87,9 +77,7 @@ def get_openapi(self) -> Any:
8777
Get the OpenAPI Spec.
8878
"""
8979
headers = {"Content-Type": "application/json;"}
90-
req = self.http_session.get(
91-
cat(self.base, "docs/?format=openapi"), headers=headers
92-
)
80+
req = self.http_session.get(cat(self.base, "docs/?format=openapi"), headers=headers)
9381
if req.ok:
9482
return req.json()
9583

@@ -144,9 +132,7 @@ def _make_call(
144132
if add_params:
145133
params.update(add_params)
146134

147-
r = getattr(self.http_session, verb)(
148-
url_override or self.url, headers=headers, params=params, json=data
149-
)
135+
r = getattr(self.http_session, verb)(url_override or self.url, headers=headers, params=params, json=data)
150136

151137
if verb == "delete":
152138
if r.ok:

pyixapi/core/response.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,8 @@ def __iter__(self) -> "RecordSet":
6868

6969
def __next__(self) -> "Record":
7070
if self._response_cache:
71-
return self.endpoint.return_obj(
72-
self._response_cache.pop(), self.endpoint.api, self.endpoint
73-
)
74-
return self.endpoint.return_obj(
75-
next(self.response), self.endpoint.api, self.endpoint
76-
)
71+
return self.endpoint.return_obj(self._response_cache.pop(), self.endpoint.api, self.endpoint)
72+
return self.endpoint.return_obj(next(self.response), self.endpoint.api, self.endpoint)
7773

7874
def __len__(self) -> int:
7975
try:
@@ -149,9 +145,7 @@ class Record:
149145

150146
url = None
151147

152-
def __init__(
153-
self, values: dict[str, Any], api: "API", endpoint: "Endpoint"
154-
) -> None:
148+
def __init__(self, values: dict[str, Any], api: "API", endpoint: "Endpoint") -> None:
155149
self._full_cache = []
156150
self._init_cache = []
157151
self.api = api
@@ -255,9 +249,7 @@ def serialize(self, nested=False, init=False):
255249
if isinstance(current_val, Record):
256250
current_val = current_val.serialize(nested=True)
257251
if isinstance(current_val, list):
258-
current_val = [
259-
v.id if isinstance(v, Record) else v for v in current_val
260-
]
252+
current_val = [v.id if isinstance(v, Record) else v for v in current_val]
261253
r[i] = current_val
262254
return r
263255

@@ -270,9 +262,7 @@ def fmt_dict(k, v):
270262
return k, v
271263

272264
current = Hashabledict({fmt_dict(k, v) for k, v in self.serialize().items()})
273-
init = Hashabledict(
274-
{fmt_dict(k, v) for k, v in self.serialize(init=True).items()}
275-
)
265+
init = Hashabledict({fmt_dict(k, v) for k, v in self.serialize(init=True).items()})
276266
return {i[0] for i in set(current.items()) ^ set(init.items())}
277267

278268
def updates(self):

pyproject.toml

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,11 @@ pytest = "*"
2525
ruff = ">=0.5,<0.7"
2626

2727
[tool.ruff]
28-
line-length = 88
28+
line-length = 120
2929

30-
exclude = [
31-
".git",
32-
".tox",
33-
".venv",
34-
"env",
35-
"_build",
36-
"build",
37-
"dist",
38-
"examples",
39-
"__main__.py",
40-
]
30+
exclude = [".git", ".tox", ".venv", "env", "_build", "build", "dist", "examples", "__main__.py"]
4131

4232
[tool.ruff.lint]
43-
preview = true
44-
4533
select = [
4634
"ASYNC", # flake8-async
4735
"B", # flake8-bugbear
@@ -78,9 +66,6 @@ indent-style = "space"
7866
skip-magic-trailing-comma = false
7967
line-ending = "auto"
8068

81-
[tool.ruff.lint.pycodestyle]
82-
max-line-length = 88
83-
8469
[tool.ruff.lint.mccabe]
8570
max-complexity = 31
8671

0 commit comments

Comments
 (0)