Skip to content

Commit bd7252c

Browse files
[PROJQUAY-1021] task: Update "Black" to version 20.8b1
1 parent 28a5200 commit bd7252c

234 files changed

Lines changed: 5310 additions & 2241 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/CI.yaml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,12 @@ jobs:
2525
- name: Install dependencies
2626
run: |
2727
python -m pip install --upgrade pip
28-
29-
# https://issues.redhat.com/browse/PROJQUAY-92
30-
# https://github.com/psf/black/issues/1207#issuecomment-566249522
31-
pip install black==19.10b0 --no-binary=regex
32-
28+
pip install black==20.8b1
3329
pip install flake8
3430
3531
- name: Check Formatting (Black)
3632
run: |
37-
# TODO(kleesc): Re-enable after buildman rewrite
38-
black --line-length=100 --target-version=py38 --check --diff . --exclude "buildman"
33+
black --line-length=100 --target-version=py38 --check --diff .
3934
4035
- name: Check Formatting (Flake8)
4136
run: |

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,5 +177,4 @@ generate-proto-py:
177177

178178

179179
black:
180-
black --line-length 100 --target-version py36 --exclude "/(\.eggs|\.git|\.hg|\.mypy_cache|\.nox|\.tox|\.venv|_build|buck-out|build|dist|buildman)/" . # TODO(kleesc): Re-enable after buildman rewrite
181-
180+
black --line-length=100 --target-version=py38 --exclude "/(\.eggs|\.git|\.hg|\.mypy_cache|\.nox|\.tox|\.venv|_build|buck-out|build|dist)/" .

app.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,11 @@ def _request_start():
155155

156156
host, port = os.getenv("PYDEV_DEBUG").split(":")
157157
pydevd_pycharm.settrace(
158-
host, port=int(port), stdoutToServer=True, stderrToServer=True, suspend=False,
158+
host,
159+
port=int(port),
160+
stdoutToServer=True,
161+
stderrToServer=True,
162+
suspend=False,
159163
)
160164

161165
logger.debug(

auth/auth_context_type.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -305,27 +305,42 @@ def to_signed_dict(self):
305305
# TODO: Remove this all once the new code is fully deployed.
306306
if self.token:
307307
dict_data.update(
308-
{"kind": "token", "token": self.token.get_code(),}
308+
{
309+
"kind": "token",
310+
"token": self.token.get_code(),
311+
}
309312
)
310313

311314
if self.oauthtoken:
312315
dict_data.update(
313-
{"kind": "oauth", "oauth": self.oauthtoken.uuid, "user": self.authed_user.username,}
316+
{
317+
"kind": "oauth",
318+
"oauth": self.oauthtoken.uuid,
319+
"user": self.authed_user.username,
320+
}
314321
)
315322

316323
if self.user or self.robot:
317324
dict_data.update(
318-
{"kind": "user", "user": self.authed_user.username,}
325+
{
326+
"kind": "user",
327+
"user": self.authed_user.username,
328+
}
319329
)
320330

321331
if self.appspecifictoken:
322332
dict_data.update(
323-
{"kind": "user", "user": self.authed_user.username,}
333+
{
334+
"kind": "user",
335+
"user": self.authed_user.username,
336+
}
324337
)
325338

326339
if self.is_anonymous:
327340
dict_data.update(
328-
{"kind": "anonymous",}
341+
{
342+
"kind": "anonymous",
343+
}
329344
)
330345

331346
# End of legacy information.

auth/context_entity.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ def description(self, entity_reference):
104104
return "user %s" % entity_reference.username
105105

106106
def analytics_id_and_public_metadata(self, entity_reference):
107-
return entity_reference.username, {"username": entity_reference.username,}
107+
return entity_reference.username, {
108+
"username": entity_reference.username,
109+
}
108110

109111

110112
class RobotEntityHandler(ContextEntityHandler):
@@ -121,7 +123,10 @@ def description(self, entity_reference):
121123
return "robot %s" % entity_reference.username
122124

123125
def analytics_id_and_public_metadata(self, entity_reference):
124-
return entity_reference.username, {"username": entity_reference.username, "is_robot": True,}
126+
return entity_reference.username, {
127+
"username": entity_reference.username,
128+
"is_robot": True,
129+
}
125130

126131

127132
class TokenEntityHandler(ContextEntityHandler):
@@ -138,7 +143,9 @@ def description(self, entity_reference):
138143
return "token %s" % entity_reference.friendly_name
139144

140145
def analytics_id_and_public_metadata(self, entity_reference):
141-
return "token:%s" % entity_reference.id, {"token": entity_reference.friendly_name,}
146+
return "token:%s" % entity_reference.id, {
147+
"token": entity_reference.friendly_name,
148+
}
142149

143150

144151
class OAuthTokenEntityHandler(ContextEntityHandler):

auth/permissions.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,20 @@
4848

4949
SCOPE_MAX_TEAM_ROLES = defaultdict(lambda: None)
5050
SCOPE_MAX_TEAM_ROLES.update(
51-
{scopes.CREATE_REPO: "creator", scopes.DIRECT_LOGIN: "admin", scopes.ORG_ADMIN: "admin",}
51+
{
52+
scopes.CREATE_REPO: "creator",
53+
scopes.DIRECT_LOGIN: "admin",
54+
scopes.ORG_ADMIN: "admin",
55+
}
5256
)
5357

5458
SCOPE_MAX_USER_ROLES = defaultdict(lambda: None)
5559
SCOPE_MAX_USER_ROLES.update(
56-
{scopes.READ_USER: "read", scopes.DIRECT_LOGIN: "admin", scopes.ADMIN_USER: "admin",}
60+
{
61+
scopes.READ_USER: "read",
62+
scopes.DIRECT_LOGIN: "admin",
63+
scopes.ADMIN_USER: "admin",
64+
}
5765
)
5866

5967

auth/registry_jwt_auth.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,18 @@
3131
"description": "List of access granted to the subject",
3232
"items": {
3333
"type": "object",
34-
"required": ["type", "name", "actions",],
34+
"required": [
35+
"type",
36+
"name",
37+
"actions",
38+
],
3539
"properties": {
3640
"type": {
3741
"type": "string",
3842
"description": "We only allow repository permissions",
39-
"enum": ["repository",],
43+
"enum": [
44+
"repository",
45+
],
4046
},
4147
"name": {
4248
"type": "string",
@@ -45,7 +51,14 @@
4551
"actions": {
4652
"type": "array",
4753
"description": "List of specific verbs which can be performed against repository",
48-
"items": {"type": "string", "enum": ["push", "pull", "*",],},
54+
"items": {
55+
"type": "string",
56+
"enum": [
57+
"push",
58+
"pull",
59+
"*",
60+
],
61+
},
4962
},
5063
},
5164
},

auth/test/test_auth_context_type.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@ def get_oauth_token(_):
2424
(ContextEntityKind.user, "devtable", model.user.get_user),
2525
],
2626
)
27-
@pytest.mark.parametrize("v1_dict_format", [(True), (False),])
27+
@pytest.mark.parametrize(
28+
"v1_dict_format",
29+
[
30+
(True),
31+
(False),
32+
],
33+
)
2834
def test_signed_auth_context(kind, entity_reference, loader, v1_dict_format, initialized_db):
2935
if kind == ContextEntityKind.anonymous:
3036
validated = ValidatedAuthContext()

auth/test/test_basic.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,5 +138,6 @@ def test_invalid_unicode_3(app):
138138
header = "basic " + b64encode(auth).decode("ascii")
139139
result = validate_basic_auth(header)
140140
assert result == ValidateResult(
141-
AuthKind.basic, error_message="Could not find robot with specified username",
141+
AuthKind.basic,
142+
error_message="Could not find robot with specified username",
142143
)

auth/test/test_registry_jwt.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@
2727

2828
def _access(typ="repository", name="somens/somerepo", actions=None):
2929
actions = [] if actions is None else actions
30-
return [{"type": typ, "name": name, "actions": actions,}]
30+
return [
31+
{
32+
"type": typ,
33+
"name": name,
34+
"actions": actions,
35+
}
36+
]
3137

3238

3339
def _delete_field(token_data, field_name):
@@ -228,7 +234,13 @@ def test_mixing_keys_e2e(initialized_db):
228234
_parse_token(deleted_key_token)
229235

230236

231-
@pytest.mark.parametrize("token", ["someunicodetoken✡", "\xc9\xad\xbd",])
237+
@pytest.mark.parametrize(
238+
"token",
239+
[
240+
"someunicodetoken✡",
241+
"\xc9\xad\xbd",
242+
],
243+
)
232244
def test_unicode_token(token):
233245
with pytest.raises(InvalidJWTException):
234246
_parse_token(token)

0 commit comments

Comments
 (0)