Skip to content

Commit a55d414

Browse files
committed
Smoosh lintage
pre-commit: disable WPS332 This action runs on Python 3.11. more lintage Disable WPS326; ignore a WPS504. ignore WPS462 Produces poor suggestions here. oidc-exchange: simplify oidc-exchange: noqa -> pylint disable oidc-exchange: add-trailing-comma fixes
1 parent 23392ea commit a55d414

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ repos:
110110
WPS110,
111111
WPS111,
112112
WPS305,
113+
WPS326,
114+
WPS332,
113115
WPS347,
114116
WPS360,
115117
WPS421,
@@ -120,6 +122,7 @@ repos:
120122
WPS440,
121123
WPS441,
122124
WPS453,
125+
WPS462,
123126
- --select
124127
- WPS
125128
additional_dependencies:

oidc-exchange.py

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
from typing import NoReturn
66
from urllib.parse import urlparse
77

8-
import id # noqa: W0622
8+
import id # pylint: disable=W0622
99
import requests
1010

1111
_GITHUB_STEP_SUMMARY = Path(os.getenv("GITHUB_STEP_SUMMARY"))
1212

13-
_TOKEN_RETRIEVAL_FAILED_MESSAGE = dedent("""
13+
_TOKEN_RETRIEVAL_FAILED_MESSAGE = dedent(
14+
"""
1415
OIDC token retrieval failed: {identity_error}
1516
1617
This generally indicates a workflow configuration error, such as insufficient
@@ -21,7 +22,7 @@
2122
permissions:
2223
id-token: write
2324
```
24-
"""
25+
""",
2526
)
2627

2728

@@ -31,7 +32,8 @@ def die(msg: str) -> NoReturn:
3132

3233
# NOTE: `msg` is Markdown formatted, so we emit only the header line to
3334
# avoid clogging the console log with a full Markdown formatted document.
34-
print(f"::error::OIDC exchange failure: {msg.splitlines()[0]}", file=sys.stderr)
35+
header = msg.splitlines()[0]
36+
print(f"::error::OIDC exchange failure: {header}", file=sys.stderr)
3537
sys.exit(1)
3638

3739

@@ -59,20 +61,20 @@ def assert_successful_audience_call(resp: requests.Response, domain: str):
5961
# This index does not support OIDC.
6062
die(
6163
"audience retrieval failed: repository at "
62-
f"{domain} does not indicate OIDC support"
64+
f"{domain} does not indicate OIDC support",
6365
)
6466
case other:
6567
# Unknown: the index may or may not support OIDC, but didn't respond with
6668
# something we expect. This can happen if the index is broken, in maintenance mode,
6769
# misconfigured, etc.
6870
die(
6971
"audience retrieval failed: repository at "
70-
f"{domain} responded with unexpected {other}"
72+
f"{domain} responded with unexpected {other}",
7173
)
7274

7375

7476
repository_url = get_normalized_input("repository-url")
75-
if not repository_url:
77+
if not repository_url: # noqa: WPS504
7678
# Easy case: no explicit repository URL, which means we're using PyPI and we can just
7779
# hardcode the exchange endpoint and OIDC audience.
7880
token_exchange_url = "https://pypi.org/_/oidc/github/mint-token"
@@ -109,14 +111,15 @@ def assert_successful_audience_call(resp: requests.Response, domain: str):
109111
# Token exchange failure normally produces a JSON error response, but
110112
# we might have hit a server error instead.
111113
die(
112-
dedent(f"""
114+
dedent(
115+
f"""
113116
Token request failed: the index produced an unexpected
114117
{mint_token_resp.status_code} response.
115118
116119
This strongly suggests a server configuration or downtime issue; wait
117120
a few minutes and try again.
118-
"""
119-
)
121+
""",
122+
),
120123
)
121124

122125
reasons = "\n".join(
@@ -125,24 +128,26 @@ def assert_successful_audience_call(resp: requests.Response, domain: str):
125128
)
126129

127130
# NOTE: Can't `dedent(...)` here because `reasons` is newline-delimited.
128-
die(f"""
131+
die(
132+
f"""
129133
Token request failed: the server refused the request for the following reasons:
130134
131135
{reasons}
132-
"""
136+
""",
133137
)
134138

135139
mint_token_payload = mint_token_resp.json()
136140
pypi_token = mint_token_payload.get("token")
137141
if pypi_token is None:
138142
die(
139-
dedent("""
143+
dedent(
144+
"""
140145
Token response error: the index gave us an invalid response.
141146
142147
This strongly suggests a server configuration or downtime issue; wait
143148
a few minutes and try again.
144-
"""
145-
)
149+
""",
150+
),
146151
)
147152

148153
# Mask the newly minted PyPI token, so that we don't accidentally leak it in logs.

0 commit comments

Comments
 (0)