Skip to content

Commit fd4988c

Browse files
committed
linted
1 parent c006316 commit fd4988c

2 files changed

Lines changed: 65 additions & 65 deletions

File tree

asyncPyGithub/Repository.py

Lines changed: 41 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ async def get_organization_repos(
7575
)
7676
return (res.status_code, [MinimalRepository(**repo) for repo in res.json()])
7777

78-
7978
@needs_authentication
8079
async def create_organization_repo(
8180
cls: Self,
@@ -84,7 +83,7 @@ async def create_organization_repo(
8483
description: str = "",
8584
homepage: str = "",
8685
private: bool = False,
87-
visibility: Literal['public', 'private'] = "public",
86+
visibility: Literal["public", "private"] = "public",
8887
has_issues: bool = True,
8988
has_projects: bool = True,
9089
has_wiki: bool = True,
@@ -100,13 +99,17 @@ async def create_organization_repo(
10099
allow_auto_merge: bool = False,
101100
delete_branch_on_merge: bool = False,
102101
use_squash_pr_title_as_default: bool = False,
103-
squash_merge_commit_title: Literal['PR_TITLE', 'COMMIT_OR_PR_TITLE'] = 'PR_TITLE',
104-
squash_merge_commit_message: Literal['PR_BODY', 'COMMIT_MESSAGES', 'BLANK'] = 'PR_BODY',
105-
merge_commit_title: Literal['PR_TITLE', 'MERGE_MESSAGE'] = 'PR_TITLE',
106-
merge_commit_message: Literal['PR_BODY', 'PR_TITLE', 'BLANK'] = 'PR_TITLE',
102+
squash_merge_commit_title: Literal[
103+
"PR_TITLE", "COMMIT_OR_PR_TITLE"
104+
] = "PR_TITLE",
105+
squash_merge_commit_message: Literal[
106+
"PR_BODY", "COMMIT_MESSAGES", "BLANK"
107+
] = "PR_BODY",
108+
merge_commit_title: Literal["PR_TITLE", "MERGE_MESSAGE"] = "PR_TITLE",
109+
merge_commit_message: Literal["PR_BODY", "PR_TITLE", "BLANK"] = "PR_TITLE",
107110
custom_properties: dict[str, str | bool | int] | None = None,
108111
) -> tuple[int, FullRepository | ErrorMessage]:
109-
112+
110113
params = {
111114
"name": name,
112115
"description": description,
@@ -131,12 +134,12 @@ async def create_organization_repo(
131134
"squash_merge_commit_title": squash_merge_commit_title,
132135
"squash_merge_commit_message": squash_merge_commit_message,
133136
"merge_commit_title": merge_commit_title,
134-
"merge_commit_message": merge_commit_message
137+
"merge_commit_message": merge_commit_message,
135138
}
136139

137140
if custom_properties:
138141
params.update(custom_properties)
139-
142+
140143
try:
141144
res = await req(
142145
fn=post,
@@ -163,9 +166,8 @@ async def create_organization_repo(
163166
endpoint=f"/orgs/{organization}/repos",
164167
),
165168
)
166-
169+
167170
return (res.status_code, FullRepository(**res.json()))
168-
169171

170172
@needs_authentication
171173
async def get_user_repo(
@@ -203,9 +205,8 @@ async def get_user_repo(
203205
endpoint="/user/repos",
204206
),
205207
)
206-
208+
207209
return (res.status_code, FullRepository(**res.json()))
208-
209210

210211
@needs_authentication
211212
async def update_repository(
@@ -215,7 +216,7 @@ async def update_repository(
215216
description: Optional[str] = None,
216217
homepage: Optional[str] = None,
217218
private: Optional[bool] = None,
218-
visibility: Optional[Literal['public', 'private']] = None,
219+
visibility: Optional[Literal["public", "private"]] = None,
219220
has_issues: Optional[bool] = None,
220221
has_projects: Optional[bool] = None,
221222
has_wiki: Optional[bool] = None,
@@ -227,19 +228,23 @@ async def update_repository(
227228
allow_auto_merge: Optional[bool] = None,
228229
delete_branch_on_merge: Optional[bool] = None,
229230
use_squash_pr_title_as_default: Optional[bool] = None,
230-
squash_merge_commit_title: Optional[Literal['PR_TITLE', 'COMMIT_OR_PR_TITLE']] = None,
231-
squash_merge_commit_message: Optional[Literal['PR_BODY', 'COMMIT_MESSAGES', 'BLANK']] = None,
232-
merge_commit_title: Optional[Literal['PR_TITLE', 'MERGE_MESSAGE']] = None,
233-
merge_commit_message: Optional[Literal['PR_BODY', 'PR_TITLE', 'BLANK']] = None,
231+
squash_merge_commit_title: Optional[
232+
Literal["PR_TITLE", "COMMIT_OR_PR_TITLE"]
233+
] = None,
234+
squash_merge_commit_message: Optional[
235+
Literal["PR_BODY", "COMMIT_MESSAGES", "BLANK"]
236+
] = None,
237+
merge_commit_title: Optional[Literal["PR_TITLE", "MERGE_MESSAGE"]] = None,
238+
merge_commit_message: Optional[Literal["PR_BODY", "PR_TITLE", "BLANK"]] = None,
234239
archived: Optional[bool] = None,
235240
allow_forking: Optional[bool] = None,
236-
web_commit_signoff_required: Optional[bool] = None
241+
web_commit_signoff_required: Optional[bool] = None,
237242
) -> tuple[int, FullRepository | ErrorMessage]:
238243
"""
239244
Updates a repository.
240245
This endpoint can be used with write access to the repository.
241246
"""
242-
247+
243248
params = {
244249
"name": name,
245250
"description": description,
@@ -263,7 +268,7 @@ async def update_repository(
263268
"merge_commit_message": merge_commit_message,
264269
"archived": archived,
265270
"allow_forking": allow_forking,
266-
"web_commit_signoff_required": web_commit_signoff_required
271+
"web_commit_signoff_required": web_commit_signoff_required,
267272
}
268273

269274
try:
@@ -292,14 +297,12 @@ async def update_repository(
292297
endpoint=f"repos/{owner}/{repo}",
293298
),
294299
)
295-
300+
296301
return (res.status_code, FullRepository(**res.json()))
297-
298302

299303
@needs_authentication
300304
async def delete_repository(
301-
owner: str,
302-
repo: str
305+
owner: str, repo: str
303306
) -> tuple[int, Optional[ErrorMessage]]:
304307
"""
305308
Deletes a repository.
@@ -330,27 +333,18 @@ async def delete_repository(
330333
endpoint=f"repos/{owner}/{repo}",
331334
),
332335
)
333-
336+
334337
return (res.status_code, None)
335-
336338

337339
@needs_authentication
338340
async def list_contributors(
339-
owner: str,
340-
repo: str,
341-
anon: bool = False,
342-
per_page: int = 30,
343-
page: int = 1
341+
owner: str, repo: str, anon: bool = False, per_page: int = 30, page: int = 1
344342
) -> tuple[int, list[Contributor] | ErrorMessage]:
345343
"""
346344
Lists contributors to the specified repository and sorts them by the number of commits per contributor in descending order. This endpoint may return information that is a few hours old because the GitHub REST API caches contributor data to improve performance.
347345
"""
348346

349-
params = {
350-
"anon": anon,
351-
"per_page": per_page,
352-
"page": page
353-
}
347+
params = {"anon": anon, "per_page": per_page, "page": page}
354348

355349
try:
356350
res = await req(
@@ -378,13 +372,14 @@ async def list_contributors(
378372
endpoint=f"repos/{owner}/{repo}/contributors",
379373
),
380374
)
381-
return (res.status_code, [Contributor(**contributor) for contributor in res.json()])
382-
375+
return (
376+
res.status_code,
377+
[Contributor(**contributor) for contributor in res.json()],
378+
)
383379

384380
@needs_authentication
385381
async def list_repository_languages(
386-
owner: str,
387-
repo: str
382+
owner: str, repo: str
388383
) -> tuple[int, dict[str, int] | ErrorMessage]:
389384
"""
390385
Lists languages for the specified repository. The value shown for each language is the number of bytes of code written in that language.
@@ -417,24 +412,17 @@ async def list_repository_languages(
417412
)
418413
return (res.status_code, res.json())
419414

420-
421415
@needs_authentication
422416
async def list_repository_tags(
423-
owner: str,
424-
repo: str,
425-
per_page: int = 30,
426-
page: int = 1
417+
owner: str, repo: str, per_page: int = 30, page: int = 1
427418
) -> tuple[int, list[Tag] | ErrorMessage]:
428419
"""
429420
Lists tags for the specified repository.
430421
This endpoint can be used without authentication, or
431422
with read access to public repositories.
432423
"""
433424

434-
params = {
435-
"per_page": per_page,
436-
"page": page
437-
}
425+
params = {"per_page": per_page, "page": page}
438426

439427
try:
440428
res = await req(
@@ -462,14 +450,12 @@ async def list_repository_tags(
462450
endpoint=f"repos/{owner}/{repo}/tags",
463451
),
464452
)
465-
453+
466454
return (res.status_code, [Tag(**tag) for tag in res.json()])
467-
468455

469456
@needs_authentication
470457
async def get_repository_topics(
471-
owner: str,
472-
repo: str
458+
owner: str, repo: str
473459
) -> tuple[int, Topics | ErrorMessage]:
474460
"""
475461
Lists topics for the specified repository.
@@ -502,6 +488,5 @@ async def get_repository_topics(
502488
endpoint=f"repos/{owner}/{repo}/topics",
503489
),
504490
)
505-
491+
506492
return (res.status_code, Topics(**res.json()))
507-

asyncPyGithub/_types/repos.py

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,24 @@
5151
class NullDict(TypedDict):
5252
type: Literal["null"]
5353

54+
5455
class CommitJSON(TypedDict):
5556
sha: str
5657
url: HttpUrl
5758

59+
5860
class TagJSON(TypedDict):
5961
name: str
6062
commit: CommitJSON
6163
zipball_url: HttpUrl
6264
tarball_url: HttpUrl
6365
node_id: str
6466

67+
6568
class TopicsJSON(TypedDict):
6669
names: List[str]
6770

71+
6872
class PermissionsJSON(TypedDict):
6973
admin: bool
7074
maintain: bool
@@ -197,7 +201,6 @@ class MinimalRepositoryJSON(TypedDict):
197201
custom_properties: NotRequired[Dict[str, Any]]
198202

199203

200-
201204
class FullRepositoryJSON(TypedDict, total=False):
202205
id: int
203206
node_id: str
@@ -476,17 +479,25 @@ class FullRepository(BaseModel):
476479
pulls_url: HttpUrl
477480
releases_url: HttpUrl
478481
ssh_url: HttpUrl = None # Optional, but typically present in full repositories.
479-
stargazers_url: HttpUrl = None # Optional, but typically present in full repositories.
480-
statuses_url: HttpUrl = None # Optional, but typically present in full repositories.
481-
subscribers_url: HttpUrl = None # Optional, but typically present in full repositories.
482-
subscription_url: HttpUrl = None # Optional, but typically present in full repositories.
482+
stargazers_url: HttpUrl = (
483+
None # Optional, but typically present in full repositories.
484+
)
485+
statuses_url: HttpUrl = (
486+
None # Optional, but typically present in full repositories.
487+
)
488+
subscribers_url: HttpUrl = (
489+
None # Optional, but typically present in full repositories.
490+
)
491+
subscription_url: HttpUrl = (
492+
None # Optional, but typically present in full repositories.
493+
)
483494
tags_url: HttpUrl = None # Optional, but typically present in full repositories.
484495
teams_url: HttpUrl = None # Optional, but typically present in full repositories.
485496
trees_url: str
486497
clone_url: HttpUrl = None # Optional, but typically present in full repositories.
487498
mirror_url: Optional[HttpUrl] = None
488499
svn_url: HttpUrl = None # Optional, but typically present in full repositories.
489-
homepage: Optional[str] = None
500+
homepage: Optional[str] = None
490501
language: Optional[str] = None
491502
forks_count: int = 0
492503
stargazers_count: int = 0
@@ -498,7 +509,7 @@ class FullRepository(BaseModel):
498509
topics: List[str] = []
499510
has_issues: bool = True
500511
has_projects: bool = True
501-
has_wiki: bool = True
512+
has_wiki: bool = True
502513
has_pages: bool = False
503514
has_downloads: bool = True
504515
has_discussions: bool = False
@@ -518,7 +529,9 @@ class FullRepository(BaseModel):
518529
allow_merge_commit: bool = True
519530
use_squash_pr_title_as_default: bool = False
520531
squash_merge_commit_title: Literal["PR_TITLE", "COMMIT_OR_PR_TITLE"] = "PR_TITLE"
521-
squash_merge_commit_message: Literal["PR_BODY", "COMMIT_MESSAGES", "BLANK"] = "PR_BODY"
532+
squash_merge_commit_message: Literal["PR_BODY", "COMMIT_MESSAGES", "BLANK"] = (
533+
"PR_BODY"
534+
)
522535
merge_commit_title: Literal["PR_TITLE", "MERGE_MESSAGE"] = "PR_TITLE"
523536
merge_commit_message: Literal["PR_BODY", "PR_TITLE", "BLANK"] = "PR_TITLE"
524537
allow_forking: bool = True
@@ -543,12 +556,14 @@ class Commit(BaseModel):
543556
sha: str
544557
url: HttpUrl
545558

559+
546560
class Tag(BaseModel):
547561
name: str
548562
commit: Commit
549563
zipball_url: HttpUrl
550564
tarball_url: HttpUrl
551565
node_id: str
552566

567+
553568
class Topics(BaseModel):
554-
names: List[str]
569+
names: List[str]

0 commit comments

Comments
 (0)