Skip to content

Commit 5565085

Browse files
authored
Merge pull request #42 from GitGuardian/agateau/spring-cleanup
Spring cleanup
2 parents 8d836ef + c94e44b commit 5565085

File tree

5 files changed

+35
-38
lines changed

5 files changed

+35
-38
lines changed

.github/workflows/test-lint.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
lint:
1616
runs-on: ubuntu-latest
1717
steps:
18-
- uses: actions/checkout@v2
18+
- uses: actions/checkout@v3
1919
- name: Set up Python 3.9
2020
uses: actions/setup-python@v1
2121
with:
@@ -40,7 +40,7 @@ jobs:
4040
os: [ubuntu-latest, macos-latest, windows-latest]
4141
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
4242
steps:
43-
- uses: actions/checkout@v2
43+
- uses: actions/checkout@v3
4444
- name: Set up Python ${{ matrix.python-version }}
4545
uses: actions/setup-python@v1
4646
with:
@@ -67,7 +67,7 @@ jobs:
6767
needs: [lint, build]
6868
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
6969
steps:
70-
- uses: actions/checkout@v2
70+
- uses: actions/checkout@v3
7171
with:
7272
fetch-depth: 0
7373
- name: Set up Python

pygitguardian/client.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def __init__(
153153
self.api_key = api_key
154154
self.session = session if isinstance(session, Session) else Session()
155155
self.timeout = timeout
156-
self.user_agent = "pygitguardian/{0} ({1};py{2})".format(
156+
self.user_agent = "pygitguardian/{} ({};py{})".format(
157157
self._version, platform.system(), platform.python_version()
158158
)
159159

@@ -163,7 +163,7 @@ def __init__(
163163
self.session.headers.update(
164164
{
165165
"User-Agent": self.user_agent,
166-
"Authorization": "Token {0}".format(api_key),
166+
"Authorization": f"Token {api_key}",
167167
},
168168
)
169169

@@ -334,9 +334,7 @@ def multi_content_scan(
334334
"""
335335
if len(documents) > MULTI_DOCUMENT_LIMIT:
336336
raise ValueError(
337-
"too many documents submitted for scan (max={0})".format(
338-
MULTI_DOCUMENT_LIMIT
339-
)
337+
f"too many documents submitted for scan (max={MULTI_DOCUMENT_LIMIT})"
340338
)
341339

342340
if all(isinstance(doc, dict) for doc in documents):

pygitguardian/models.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def __init__(self, document: str, filename: Optional[str] = None, **kwargs: Any)
100100
self.filename = filename
101101

102102
def __repr__(self) -> str:
103-
return "filename:{0}, document:{1}".format(self.filename, self.document)
103+
return f"filename:{self.filename}, document:{self.document}"
104104

105105

106106
class DetailSchema(BaseSchema):
@@ -134,7 +134,7 @@ def __init__(self, detail: str, **kwargs: Any) -> None:
134134
self.detail = detail
135135

136136
def __repr__(self) -> str:
137-
return "{0}:{1}".format(self.status_code, self.detail)
137+
return f"{self.status_code}:{self.detail}"
138138

139139

140140
class MatchSchema(BaseSchema):
@@ -185,12 +185,12 @@ def __init__(
185185

186186
def __repr__(self) -> str:
187187
return (
188-
"match:{0}, "
189-
"match_type:{1}, "
190-
"line_start:{2}, "
191-
"line_end:{3}, "
192-
"index_start:{4}, "
193-
"index_end:{5}".format(
188+
"match:{}, "
189+
"match_type:{}, "
190+
"line_start:{}, "
191+
"line_end:{}, "
192+
"index_start:{}, "
193+
"index_end:{}".format(
194194
self.match,
195195
self.match_type,
196196
repr(self.line_start),
@@ -245,9 +245,9 @@ def is_secret(self) -> bool:
245245

246246
def __repr__(self) -> str:
247247
return (
248-
"break_type:{0}, "
249-
"policy:{1}, "
250-
"matches: {2}".format(self.break_type, self.policy, repr(self.matches))
248+
"break_type:{}, "
249+
"policy:{}, "
250+
"matches: {}".format(self.break_type, self.policy, repr(self.matches))
251251
)
252252

253253

@@ -319,15 +319,15 @@ def has_secrets(self) -> bool:
319319

320320
def __repr__(self) -> str:
321321
return (
322-
"policy_break_count:{0}, "
323-
"policies:{1}, "
324-
"policy_breaks: {2}".format(
322+
"policy_break_count:{}, "
323+
"policies:{}, "
324+
"policy_breaks: {}".format(
325325
self.policy_break_count, self.policies, self.policy_breaks
326326
)
327327
)
328328

329329
def __str__(self) -> str:
330-
return "{0} policy breaks from the evaluated policies: {1}".format(
330+
return "{} policy breaks from the evaluated policies: {}".format(
331331
self.policy_break_count,
332332
", ".join(policy_break.policy for policy_break in self.policy_breaks),
333333
)
@@ -391,10 +391,10 @@ def has_secrets(self) -> bool:
391391
return any(scan_result.has_secrets for scan_result in self.scan_results)
392392

393393
def __repr__(self) -> str:
394-
return "scan_results:{0}".format(self.scan_results)
394+
return f"scan_results:{self.scan_results}"
395395

396396
def __str__(self) -> str:
397-
return "{0} scan results containing {1} policy breaks".format(
397+
return "{} scan results containing {} policy breaks".format(
398398
len(self.scan_results),
399399
len(
400400
[
@@ -441,10 +441,10 @@ def __init__(
441441

442442
def __repr__(self) -> str:
443443
return (
444-
"count:{0}, "
445-
"limit:{1}, "
446-
"remaining:{2}, "
447-
"since:{3}".format(
444+
"count:{}, "
445+
"limit:{}, "
446+
"remaining:{}, "
447+
"since:{}".format(
448448
self.count, self.limit, self.remaining, self.since.isoformat()
449449
)
450450
)
@@ -479,7 +479,7 @@ def __init__(self, content: Quota, **kwargs: Any) -> None:
479479
self.content = content
480480

481481
def __repr__(self) -> str:
482-
return "content:{0}".format(repr(self.content))
482+
return f"content:{repr(self.content)}"
483483

484484

485485
class HealthCheckResponseSchema(BaseSchema):
@@ -508,10 +508,10 @@ def __init__(
508508

509509
def __repr__(self) -> str:
510510
return (
511-
"detail:{0}, "
512-
"status_code:{1}, "
513-
"app version:{2}, "
514-
"secrets engine version:{3}".format(
511+
"detail:{}, "
512+
"status_code:{}, "
513+
"app version:{}, "
514+
"secrets engine version:{}".format(
515515
self.detail,
516516
self.status_code,
517517
self.app_version or "",

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import io
21
import os
32
import re
43

@@ -11,7 +10,7 @@
1110

1211
def read(*args: str) -> str:
1312
"""Reads complete file contents."""
14-
return io.open(os.path.join(HERE, *args), encoding="utf-8").read()
13+
return open(os.path.join(HERE, *args), encoding="utf-8").read()
1514

1615

1716
def get_version() -> str:

tests/test_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def test_client_creation(
221221
assert client.api_key == api_key
222222
assert client.timeout == timeout
223223
assert user_agent in client.session.headers["User-Agent"]
224-
assert client.session.headers["Authorization"] == "Token {0}".format(api_key)
224+
assert client.session.headers["Authorization"] == f"Token {api_key}"
225225

226226

227227
@pytest.mark.parametrize(
@@ -257,7 +257,7 @@ def test_client__url_from_endpoint(base_uries, version, endpoints_and_urls):
257257
for endpoint, expected_url in endpoints_and_urls:
258258
assert (
259259
client._url_from_endpoint(endpoint, version) == expected_url
260-
), "Could not get the expected URL for base_uri=`{}`".format(base_uri)
260+
), f"Could not get the expected URL for base_uri=`{base_uri}`"
261261

262262

263263
@my_vcr.use_cassette

0 commit comments

Comments
 (0)