Skip to content

Commit e113e37

Browse files
Add pyupgrade to pre-commit configuration (PyGithub#1783)
To help us switch to f-strings and other 3.6+ changes, add pyupgrade to our pre-commit configuration to keep the codebase clean.
1 parent 2432cff commit e113e37

File tree

220 files changed

+383
-815
lines changed

Some content is hidden

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

220 files changed

+383
-815
lines changed

.pre-commit-config.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,9 @@ repos:
2424
args:
2525
- --ignore-words-list="bloaded,nto,pullrequest,pullrequests,thi,tim,wan,Wan,chang,Chang"
2626
- --quiet-level=2
27+
- repo: https://github.com/asottile/pyupgrade
28+
rev: v2.7.4
29+
hooks:
30+
- id: pyupgrade
31+
args:
32+
- --py36-plus

doc/conf.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2012 Vincent Jacques <[email protected]> #
@@ -61,8 +59,8 @@
6159
master_doc = "index"
6260

6361
# General information about the project.
64-
project = u"PyGithub"
65-
copyright = u"%d, Vincent Jacques" % datetime.date.today().year
62+
project = "PyGithub"
63+
copyright = "%d, Vincent Jacques" % datetime.date.today().year
6664

6765
# The version info for the project you're documenting, acts as replacement for
6866
# |version| and |release|, also used in various other places throughout the
@@ -204,7 +202,7 @@
204202
# Grouping the document tree into LaTeX files. List of tuples
205203
# (source start file, target name, title, author, documentclass [howto/manual]).
206204
latex_documents = [
207-
("index", "PyGithub.tex", u"PyGithub Documentation", u"Vincent Jacques", "manual"),
205+
("index", "PyGithub.tex", "PyGithub Documentation", "Vincent Jacques", "manual"),
208206
]
209207

210208
# The name of an image file (relative to this directory) to place at the top of
@@ -232,7 +230,7 @@
232230

233231
# One entry per manual page. List of tuples
234232
# (source start file, name, description, authors, manual section).
235-
man_pages = [("index", "pygithub", u"PyGithub Documentation", [u"Vincent Jacques"], 1)]
233+
man_pages = [("index", "pygithub", "PyGithub Documentation", ["Vincent Jacques"], 1)]
236234

237235
# If true, show URL addresses after external links.
238236
# man_show_urls = False
@@ -247,8 +245,8 @@
247245
(
248246
"index",
249247
"PyGithub",
250-
u"PyGithub Documentation",
251-
u"Vincent Jacques",
248+
"PyGithub Documentation",
249+
"Vincent Jacques",
252250
"PyGithub",
253251
"One line description of project.",
254252
"Miscellaneous",

github/AccessToken.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2019 Rigas Papathanasopoulos <[email protected]> #

github/ApplicationOAuth.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ###########################
42
# #
53
# Copyright 2019 Rigas Papathanasopoulos <[email protected]> #
@@ -75,7 +73,7 @@ def get_login_url(self, redirect_uri=None, state=None, login=None):
7573
parameters = urllib.parse.urlencode(parameters)
7674

7775
base_url = "https://github.com/login/oauth/authorize"
78-
return u"{}?{}".format(base_url, parameters)
76+
return f"{base_url}?{parameters}"
7977

8078
def get_access_token(self, code, state=None):
8179
"""

github/AuthenticatedUser.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2012 Steve English <[email protected]> #

github/Authorization.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2012 Vincent Jacques <[email protected]> #

github/AuthorizationApplication.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2012 Vincent Jacques <[email protected]> #

github/Branch.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2012 Vincent Jacques <[email protected]> #

github/BranchProtection.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2018 Steve Kowalik <[email protected]> #

github/CheckRun.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2020 Dhruv Manilawala <[email protected]> #

github/CheckRunAnnotation.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2020 Dhruv Manilawala <[email protected]> #

github/CheckRunOutput.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2020 Dhruv Manilawala <[email protected]> #

github/CheckSuite.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2020 Raju Subramanian <[email protected]> #

github/Clones.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2018 Justin Kufro <[email protected]> #

github/Commit.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2012 Vincent Jacques <[email protected]> #

github/CommitCombinedStatus.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2016 Jannis Gebauer <[email protected]> #

github/CommitComment.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2012 Vincent Jacques <[email protected]> #

github/CommitStats.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2012 Vincent Jacques <[email protected]> #

github/CommitStatus.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2012 Vincent Jacques <[email protected]> #

github/Comparison.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2012 Vincent Jacques <[email protected]> #

github/Consts.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2013 AKFish <[email protected]> #

github/ContentFile.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2012 Vincent Jacques <[email protected]> #

github/Deployment.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2020 Steve Kowalik <[email protected]> #

github/DeploymentStatus.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2020 Colby Gallup <[email protected]> #

github/Download.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2012 Vincent Jacques <[email protected]> #

github/Event.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2012 Vincent Jacques <[email protected]> #

github/File.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2012 Vincent Jacques <[email protected]> #

github/Gist.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2012 Steve English <[email protected]> #

github/GistComment.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2012 Vincent Jacques <[email protected]> #

github/GistFile.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2012 Vincent Jacques <[email protected]> #

github/GistHistoryState.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2012 Vincent Jacques <[email protected]> #

github/GitAuthor.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2012 Vincent Jacques <[email protected]> #

github/GitBlob.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2012 Vincent Jacques <[email protected]> #

github/GitCommit.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2012 Vincent Jacques <[email protected]> #

github/GitObject.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2012 Vincent Jacques <[email protected]> #

github/GitRef.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2012 Vincent Jacques <[email protected]> #

github/GitRelease.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2015 Ed Holland <[email protected]> #

github/GitReleaseAsset.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2017 Chris McBride <[email protected]> #

github/GitTag.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2012 Vincent Jacques <[email protected]> #

github/GitTree.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2012 Vincent Jacques <[email protected]> #

github/GitTreeElement.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2012 Vincent Jacques <[email protected]> #

github/GithubApp.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2020 Raju Subramanian <[email protected]> #

github/GithubException.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2012 Vincent Jacques <[email protected]> #

github/GithubObject.py

+6-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2012 Vincent Jacques <[email protected]> #
@@ -66,7 +64,7 @@ def value(self):
6664
)
6765

6866

69-
class GithubObject(object):
67+
class GithubObject:
7068
"""
7169
Base class for all classes representing objects returned by the API.
7270
"""
@@ -233,13 +231,10 @@ def _makeDictOfStringsToClassesAttribute(self, klass, value):
233231
for key, element in value.items()
234232
):
235233
return _ValuedAttribute(
236-
dict(
237-
(
238-
key,
239-
klass(self._requester, self._headers, element, completed=False),
240-
)
234+
{
235+
key: klass(self._requester, self._headers, element, completed=False)
241236
for key, element in value.items()
242-
)
237+
}
243238
)
244239
else:
245240
return _BadAttribute(value, {str: dict})
@@ -269,8 +264,8 @@ def format_params(params):
269264
if isinstance(v, bytes):
270265
v = v.decode("utf-8")
271266
if isinstance(v, str):
272-
v = '"{v}"'.format(v=v)
273-
yield u"{k}={v}".format(k=k, v=v)
267+
v = f'"{v}"'
268+
yield f"{k}={v}"
274269

275270
return "{class_name}({params})".format(
276271
class_name=self.__class__.__name__,

github/GitignoreTemplate.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2012 Vincent Jacques <[email protected]> #

github/Hook.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2012 Vincent Jacques <[email protected]> #

github/HookDescription.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2012 Vincent Jacques <[email protected]> #

github/HookResponse.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2012 Vincent Jacques <[email protected]> #

github/InputFileContent.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
############################ Copyrights and license ############################
42
# #
53
# Copyright 2012 Vincent Jacques <[email protected]> #
@@ -31,7 +29,7 @@
3129
import github.GithubObject
3230

3331

34-
class InputFileContent(object):
32+
class InputFileContent:
3533
"""
3634
This class represents InputFileContents
3735
"""

0 commit comments

Comments
 (0)