Skip to content

Commit c2831a5

Browse files
committed
update lint
1 parent de33103 commit c2831a5

7 files changed

Lines changed: 31 additions & 29 deletions

File tree

examples/cost_estimate.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,11 @@ def main():
6464
ce = client.cost_estimates.read(ce_id)
6565
print(f"ID: {ce.id}")
6666
print(f"Status: {ce.status}")
67-
print(f"Resources: {ce.resources_count} "
68-
f"(matched={ce.matched_resources_count}, "
69-
f"unmatched={ce.unmatched_resources_count})")
67+
print(
68+
f"Resources: {ce.resources_count} "
69+
f"(matched={ce.matched_resources_count}, "
70+
f"unmatched={ce.unmatched_resources_count})"
71+
)
7072
print(f"Prior monthly cost: {ce.prior_monthly_cost}")
7173
print(f"Proposed monthly cost: {ce.proposed_monthly_cost}")
7274
print(f"Delta monthly cost: {ce.delta_monthly_cost}")

examples/plan_export.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ def _print_header(title: str):
1818

1919

2020
def main():
21-
parser = argparse.ArgumentParser(
22-
description="Plan exports demo for python-tfe SDK"
23-
)
21+
parser = argparse.ArgumentParser(description="Plan exports demo for python-tfe SDK")
2422
parser.add_argument(
2523
"--address", default=os.getenv("TFE_ADDRESS", "https://app.terraform.io")
2624
)

examples/registry.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ def main() -> int:
5252
if args.search:
5353
_print_header(f"Searching modules for: {args.search}")
5454
opts = PublicRegistrySearchOptions(provider=args.provider)
55-
for m in itertools.islice(registry.search_modules(args.search, opts), args.limit):
55+
for m in itertools.islice(
56+
registry.search_modules(args.search, opts), args.limit
57+
):
5658
print(f" {m.id:50} downloads={m.downloads} verified={m.verified}")
5759
return 0
5860

@@ -75,8 +77,10 @@ def main() -> int:
7577

7678
_print_header("Download metrics")
7779
summary = registry.downloads_summary(args.namespace, args.name, args.provider)
78-
print(f" week={summary.week} month={summary.month} "
79-
f"year={summary.year} total={summary.total}")
80+
print(
81+
f" week={summary.week} month={summary.month} "
82+
f"year={summary.year} total={summary.total}"
83+
)
8084

8185
return 0
8286

src/pytfe/resources/assessment_result.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ def read(self, assessment_result_id: str) -> AssessmentResult:
4444
"""Read an assessment result by its ID."""
4545
if not valid_string_id(assessment_result_id):
4646
raise InvalidAssessmentResultIDError()
47-
r = self.t.request(
48-
"GET", f"/api/v2/assessment-results/{assessment_result_id}"
49-
)
47+
r = self.t.request("GET", f"/api/v2/assessment-results/{assessment_result_id}")
5048
body = r.json()
5149
data = (body or {}).get("data") or {} if isinstance(body, dict) else {}
5250
included = body.get("included") if isinstance(body, dict) else None

src/pytfe/resources/cidr_range_list.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,7 @@ def list_cidr_ranges(self, cidr_range_list_id: str) -> Iterator[CIDRRange]:
135135
if not valid_string_id(cidr_range_list_id):
136136
raise InvalidCIDRRangeListIDError()
137137
path = (
138-
f"/api/v2/cidr-range-lists/{cidr_range_list_id}"
139-
"/relationships/cidr-ranges"
138+
f"/api/v2/cidr-range-lists/{cidr_range_list_id}/relationships/cidr-ranges"
140139
)
141140
for item in self._list(path):
142141
yield _cidr_range_from(item)
@@ -216,9 +215,7 @@ def read(self, cidr_range_id: str) -> CIDRRange:
216215
body = r.json()
217216
return _cidr_range_from(body["data"], body.get("included"))
218217

219-
def update(
220-
self, cidr_range_id: str, options: CIDRRangeUpdateOptions
221-
) -> CIDRRange:
218+
def update(self, cidr_range_id: str, options: CIDRRangeUpdateOptions) -> CIDRRange:
222219
"""Update a CIDR range by its ID."""
223220
if not valid_string_id(cidr_range_id):
224221
raise InvalidCIDRRangeIDError()

src/pytfe/resources/registry.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ def _query_params(options: Any) -> dict[str, Any]:
5757
if options is None:
5858
return {}
5959
dumped = options.model_dump(by_alias=True, exclude_none=True, mode="json")
60-
return {k: (str(v).lower() if isinstance(v, bool) else v) for k, v in dumped.items()}
60+
return {
61+
k: (str(v).lower() if isinstance(v, bool) else v) for k, v in dumped.items()
62+
}
6163

6264

6365
class Registry(_Service):
@@ -75,7 +77,11 @@ def __init__(self, t: HTTPTransport, base_url: str | None = None) -> None:
7577
self.base_url = (base_url or DEFAULT_REGISTRY_URL).rstrip("/")
7678

7779
def _get(
78-
self, path: str, *, params: dict[str, Any] | None = None, allow_redirects: bool = True
80+
self,
81+
path: str,
82+
*,
83+
params: dict[str, Any] | None = None,
84+
allow_redirects: bool = True,
7985
) -> Any:
8086
return self.t.request(
8187
"GET",
@@ -148,9 +154,7 @@ def get_module(
148154
) -> PublicRegistryModule:
149155
"""Read a specific version of a module for a single provider."""
150156
self._validate(namespace, name, provider, version)
151-
body = self._get(
152-
f"/v1/modules/{namespace}/{name}/{provider}/{version}"
153-
).json()
157+
body = self._get(f"/v1/modules/{namespace}/{name}/{provider}/{version}").json()
154158
return PublicRegistryModule.model_validate(body)
155159

156160
def list_versions(
@@ -162,9 +166,7 @@ def list_versions(
162166
dependency modules the registry also returns are not included.
163167
"""
164168
self._validate(namespace, name, provider)
165-
body = self._get(
166-
f"/v1/modules/{namespace}/{name}/{provider}/versions"
167-
).json()
169+
body = self._get(f"/v1/modules/{namespace}/{name}/{provider}/versions").json()
168170
modules = (body or {}).get("modules") or [] if isinstance(body, dict) else []
169171
if not modules:
170172
return PublicRegistryModuleVersions()
@@ -183,9 +185,7 @@ def download_url(
183185
)
184186
return self._x_terraform_get(resp)
185187

186-
def latest_download_url(
187-
self, namespace: str, name: str, provider: str
188-
) -> str:
188+
def latest_download_url(self, namespace: str, name: str, provider: str) -> str:
189189
"""Return the latest version's source location (``X-Terraform-Get``).
190190
191191
The endpoint 302-redirects to the versioned download; the redirect is

tests/units/test_registry.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ def test_custom_base_url_strips_trailing_slash(self, mock_transport):
5353

5454
def test_list_modules_paginates_and_strips_auth(self, service, mock_transport):
5555
page1 = self._json(
56-
{"meta": {"next_offset": 2}, "modules": [{"id": "a/b/c/1"}, {"id": "a/b/c/2"}]}
56+
{
57+
"meta": {"next_offset": 2},
58+
"modules": [{"id": "a/b/c/1"}, {"id": "a/b/c/2"}],
59+
}
5760
)
5861
page2 = self._json({"meta": {}, "modules": [{"id": "a/b/c/3"}]})
5962
mock_transport.request.side_effect = [page1, page2]

0 commit comments

Comments
 (0)