1
1
import os
2
- from pathlib import Path
3
2
import sys
3
+ from pathlib import Path
4
4
from textwrap import dedent
5
5
from typing import NoReturn
6
6
from urllib .parse import urlparse
7
7
8
- import id
8
+ import id # pylint: disable=W0622
9
9
import requests
10
10
11
11
_GITHUB_STEP_SUMMARY = Path (os .getenv ("GITHUB_STEP_SUMMARY" ))
22
22
permissions:
23
23
id-token: write
24
24
```
25
- """
25
+ """ ,
26
26
)
27
27
28
28
@@ -32,7 +32,8 @@ def die(msg: str) -> NoReturn:
32
32
33
33
# NOTE: `msg` is Markdown formatted, so we emit only the header line to
34
34
# avoid clogging the console log with a full Markdown formatted document.
35
- 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 )
36
37
sys .exit (1 )
37
38
38
39
@@ -60,20 +61,20 @@ def assert_successful_audience_call(resp: requests.Response, domain: str):
60
61
# This index does not support OIDC.
61
62
die (
62
63
"audience retrieval failed: repository at "
63
- f"{ domain } does not indicate OIDC support"
64
+ f"{ domain } does not indicate OIDC support" ,
64
65
)
65
66
case other :
66
67
# Unknown: the index may or may not support OIDC, but didn't respond with
67
68
# something we expect. This can happen if the index is broken, in maintenance mode,
68
69
# misconfigured, etc.
69
70
die (
70
71
"audience retrieval failed: repository at "
71
- f"{ domain } responded with unexpected { other } "
72
+ f"{ domain } responded with unexpected { other } " ,
72
73
)
73
74
74
75
75
76
repository_url = get_normalized_input ("repository-url" )
76
- if not repository_url :
77
+ if not repository_url : # noqa: WPS504
77
78
# Easy case: no explicit repository URL, which means we're using PyPI and we can just
78
79
# hardcode the exchange endpoint and OIDC audience.
79
80
token_exchange_url = "https://pypi.org/_/oidc/github/mint-token"
@@ -117,8 +118,8 @@ def assert_successful_audience_call(resp: requests.Response, domain: str):
117
118
118
119
This strongly suggests a server configuration or downtime issue; wait
119
120
a few minutes and try again.
120
- """
121
- )
121
+ """ ,
122
+ ),
122
123
)
123
124
124
125
reasons = "\n " .join (
@@ -132,7 +133,7 @@ def assert_successful_audience_call(resp: requests.Response, domain: str):
132
133
Token request failed: the server refused the request for the following reasons:
133
134
134
135
{ reasons }
135
- """
136
+ """ ,
136
137
)
137
138
138
139
mint_token_payload = mint_token_resp .json ()
@@ -145,8 +146,8 @@ def assert_successful_audience_call(resp: requests.Response, domain: str):
145
146
146
147
This strongly suggests a server configuration or downtime issue; wait
147
148
a few minutes and try again.
148
- """
149
- )
149
+ """ ,
150
+ ),
150
151
)
151
152
152
153
# Mask the newly minted PyPI token, so that we don't accidentally leak it in logs.
0 commit comments