Skip to content

Commit 70e7475

Browse files
committed
Format the whole repository with ruff
1 parent c174e35 commit 70e7475

Some content is hidden

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

73 files changed

+2929
-2069
lines changed

build_tag.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import platform, sys
22

3-
py = {'CPython': 'cp', 'PyPy': 'pp'}[platform.python_implementation()]
4-
print(f'{py}{sys.version_info.major}{sys.version_info.minor}')
3+
py = {"CPython": "cp", "PyPy": "pp"}[platform.python_implementation()]
4+
print(f"{py}{sys.version_info.major}{sys.version_info.minor}")

docs/conf.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@
1212
# add these directories to sys.path here. If the directory is relative to the
1313
# documentation root, use os.path.abspath to make it absolute, like shown here.
1414
#
15-
sys.path.insert(0, os.path.abspath('..'))
15+
sys.path.insert(0, os.path.abspath(".."))
1616

1717

1818
# -- Project information -----------------------------------------------------
1919

20-
project = 'pygit2'
21-
copyright = '2010-2024 The pygit2 contributors'
22-
#author = ''
20+
project = "pygit2"
21+
copyright = "2010-2024 The pygit2 contributors"
22+
# author = ''
2323

2424
# The full version, including alpha/beta/rc tags
25-
release = '1.14.1'
25+
release = "1.14.1"
2626

2727

2828
# -- General configuration ---------------------------------------------------
@@ -31,27 +31,27 @@
3131
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3232
# ones.
3333
extensions = [
34-
'sphinx.ext.autodoc',
34+
"sphinx.ext.autodoc",
3535
]
3636

3737
# Add any paths that contain templates here, relative to this directory.
38-
templates_path = ['_templates']
38+
templates_path = ["_templates"]
3939

4040
# List of patterns, relative to source directory, that match files and
4141
# directories to ignore when looking for source files.
4242
# This pattern also affects html_static_path and html_extra_path.
43-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
43+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
4444

4545

4646
# -- Options for HTML output -------------------------------------------------
4747

4848
# The theme to use for HTML and HTML Help pages. See the documentation for
4949
# a list of builtin themes.
5050
#
51-
html_theme = 'sphinx_rtd_theme'
52-
html_theme_path = ['_themes']
51+
html_theme = "sphinx_rtd_theme"
52+
html_theme_path = ["_themes"]
5353

5454
# Add any paths that contain custom static files (such as style sheets) here,
5555
# relative to this directory. They are copied after the builtin static files,
5656
# so a file named "default.css" will overwrite the builtin "default.css".
57-
html_static_path = ['_static']
57+
html_static_path = ["_static"]

pygit2/__init__.py

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,17 @@
6666

6767

6868
def init_repository(
69-
path: typing.Union[str, bytes, PathLike, None],
70-
bare: bool = False,
71-
flags: enums.RepositoryInitFlag = enums.RepositoryInitFlag.MKPATH,
72-
mode: typing.Union[int, enums.RepositoryInitMode] = enums.RepositoryInitMode.SHARED_UMASK,
73-
workdir_path: typing.Optional[str] = None,
74-
description: typing.Optional[str] = None,
75-
template_path: typing.Optional[str] = None,
76-
initial_head: typing.Optional[str] = None,
77-
origin_url: typing.Optional[str] = None
69+
path: typing.Union[str, bytes, PathLike, None],
70+
bare: bool = False,
71+
flags: enums.RepositoryInitFlag = enums.RepositoryInitFlag.MKPATH,
72+
mode: typing.Union[
73+
int, enums.RepositoryInitMode
74+
] = enums.RepositoryInitMode.SHARED_UMASK,
75+
workdir_path: typing.Optional[str] = None,
76+
description: typing.Optional[str] = None,
77+
template_path: typing.Optional[str] = None,
78+
initial_head: typing.Optional[str] = None,
79+
origin_url: typing.Optional[str] = None,
7880
) -> Repository:
7981
"""
8082
Creates a new Git repository in the given *path*.
@@ -101,40 +103,39 @@ def init_repository(
101103
"""
102104
# Pre-process input parameters
103105
if path is None:
104-
raise TypeError('Expected string type for path, found None.')
106+
raise TypeError("Expected string type for path, found None.")
105107

106108
if bare:
107109
flags |= enums.RepositoryInitFlag.BARE
108110

109111
# Options
110-
options = ffi.new('git_repository_init_options *')
111-
C.git_repository_init_options_init(options,
112-
C.GIT_REPOSITORY_INIT_OPTIONS_VERSION)
112+
options = ffi.new("git_repository_init_options *")
113+
C.git_repository_init_options_init(options, C.GIT_REPOSITORY_INIT_OPTIONS_VERSION)
113114
options.flags = int(flags)
114115
options.mode = mode
115116

116117
if workdir_path:
117-
workdir_path_ref = ffi.new('char []', to_bytes(workdir_path))
118+
workdir_path_ref = ffi.new("char []", to_bytes(workdir_path))
118119
options.workdir_path = workdir_path_ref
119120

120121
if description:
121-
description_ref = ffi.new('char []', to_bytes(description))
122+
description_ref = ffi.new("char []", to_bytes(description))
122123
options.description = description_ref
123124

124125
if template_path:
125-
template_path_ref = ffi.new('char []', to_bytes(template_path))
126+
template_path_ref = ffi.new("char []", to_bytes(template_path))
126127
options.template_path = template_path_ref
127128

128129
if initial_head:
129-
initial_head_ref = ffi.new('char []', to_bytes(initial_head))
130+
initial_head_ref = ffi.new("char []", to_bytes(initial_head))
130131
options.initial_head = initial_head_ref
131132

132133
if origin_url:
133-
origin_url_ref = ffi.new('char []', to_bytes(origin_url))
134+
origin_url_ref = ffi.new("char []", to_bytes(origin_url))
134135
options.origin_url = origin_url_ref
135136

136137
# Call
137-
crepository = ffi.new('git_repository **')
138+
crepository = ffi.new("git_repository **")
138139
err = C.git_repository_init_ext(crepository, to_bytes(path), options)
139140
check_error(err)
140141

@@ -143,8 +144,15 @@ def init_repository(
143144

144145

145146
def clone_repository(
146-
url, path, bare=False, repository=None, remote=None,
147-
checkout_branch=None, callbacks=None, depth=0):
147+
url,
148+
path,
149+
bare=False,
150+
repository=None,
151+
remote=None,
152+
checkout_branch=None,
153+
callbacks=None,
154+
depth=0,
155+
):
148156
"""
149157
Clones a new Git repository from *url* in the given *path*.
150158
@@ -200,11 +208,11 @@ def clone_repository(
200208
opts.fetch_opts.depth = depth
201209

202210
if checkout_branch:
203-
checkout_branch_ref = ffi.new('char []', to_bytes(checkout_branch))
211+
checkout_branch_ref = ffi.new("char []", to_bytes(checkout_branch))
204212
opts.checkout_branch = checkout_branch_ref
205213

206214
with git_fetch_options(payload, opts=opts.fetch_opts):
207-
crepo = ffi.new('git_repository **')
215+
crepo = ffi.new("git_repository **")
208216
err = C.git_clone(crepo, to_bytes(url), to_bytes(path), opts)
209217
payload.check_error(err)
210218

pygit2/_build.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,41 +34,41 @@
3434
#
3535
# The version number of pygit2
3636
#
37-
__version__ = '1.14.1'
37+
__version__ = "1.14.1"
3838

3939

4040
#
4141
# Utility functions to get the paths required for bulding extensions
4242
#
4343
def _get_libgit2_path():
4444
# LIBGIT2 environment variable takes precedence
45-
libgit2_path = os.getenv('LIBGIT2')
45+
libgit2_path = os.getenv("LIBGIT2")
4646
if libgit2_path is not None:
4747
return Path(libgit2_path)
4848

4949
# Default
50-
if os.name == 'nt':
51-
return Path(r'%s\libgit2' % os.getenv('ProgramFiles'))
52-
return Path('/usr/local')
50+
if os.name == "nt":
51+
return Path(r"%s\libgit2" % os.getenv("ProgramFiles"))
52+
return Path("/usr/local")
5353

5454

5555
def get_libgit2_paths():
5656
# Base path
5757
path = _get_libgit2_path()
5858

5959
# Library dirs
60-
libgit2_lib = os.getenv('LIBGIT2_LIB')
60+
libgit2_lib = os.getenv("LIBGIT2_LIB")
6161
if libgit2_lib is None:
62-
library_dirs = [path / 'lib', path / 'lib64']
62+
library_dirs = [path / "lib", path / "lib64"]
6363
else:
6464
library_dirs = [libgit2_lib]
6565

66-
include_dirs = [path / 'include']
66+
include_dirs = [path / "include"]
6767
return (
68-
path / 'bin',
68+
path / "bin",
6969
{
70-
'libraries': ['git2'],
71-
'include_dirs': [str(x) for x in include_dirs],
72-
'library_dirs': [str(x) for x in library_dirs],
73-
}
70+
"libraries": ["git2"],
71+
"include_dirs": [str(x) for x in include_dirs],
72+
"library_dirs": [str(x) for x in library_dirs],
73+
},
7474
)

0 commit comments

Comments
 (0)