Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix docstring #1228

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ apidocs:
fix:
ruff check --fix .

reformat:
ruff format .

.PHONY: codespell

codespell:
Expand Down
43 changes: 21 additions & 22 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,47 +17,47 @@
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.abspath('..'))
sys.path.insert(0, os.path.abspath(".."))
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__))))
dulwich = __import__('dulwich')
dulwich = __import__("dulwich")

# -- General configuration ----------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.ifconfig',
'sphinx.ext.intersphinx',
'sphinx.ext.napoleon',
"sphinx.ext.autodoc",
"sphinx.ext.ifconfig",
"sphinx.ext.intersphinx",
"sphinx.ext.napoleon",
]

autoclass_content = "both"

# Add any paths that contain templates here, relative to this directory.
templates_path = ['templates']
templates_path = ["templates"]

# The suffix of source filenames.
source_suffix = '.txt'
source_suffix = ".txt"

# The encoding of source files.
# source_encoding = 'utf-8'

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# General information about the project.
project = 'dulwich'
copyright = '2011-2023 Jelmer Vernooij'
project = "dulwich"
copyright = "2011-2023 Jelmer Vernooij"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '.'.join(map(str, dulwich.__version__[:2]))
version = ".".join(map(str, dulwich.__version__[:2]))
# The full version, including alpha/beta/rc tags.
release = '.'.join(map(str, dulwich.__version__))
release = ".".join(map(str, dulwich.__version__))

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand All @@ -74,7 +74,7 @@

# List of directories, relative to source directory, that shouldn't be searched
# for source files.
exclude_trees = ['build']
exclude_trees = ["build"]

# The reST default role (used for this markup: `text`) to use for all
# documents.
Expand All @@ -92,7 +92,7 @@
# show_authors = False

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"

# A list of ignored prefixes for module index sorting.
# modindex_common_prefix = []
Expand All @@ -103,15 +103,15 @@
# The theme to use for HTML and HTML Help pages. Major themes that come with
# Sphinx are currently 'default' and 'sphinxdoc'.
# html_theme = 'default'
html_theme = 'agogo'
html_theme = "agogo"

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
# html_theme_options = {}

# Add any paths that contain custom themes here, relative to this directory.
html_theme_path = ['theme']
html_theme_path = ["theme"]

# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
Expand Down Expand Up @@ -170,7 +170,7 @@
# html_file_suffix = ''

# Output file base name for HTML help builder.
htmlhelp_basename = 'dulwichdoc'
htmlhelp_basename = "dulwichdoc"


# -- Options for LaTeX output ------------------------------------------------
Expand All @@ -185,8 +185,7 @@
# (source start file, target name, title, author, documentclass
# [howto/manual]).
latex_documents = [
('index', 'dulwich.tex', 'dulwich Documentation',
'Jelmer Vernooij', 'manual'),
("index", "dulwich.tex", "dulwich Documentation", "Jelmer Vernooij", "manual"),
]

# The name of an image file (relative to this directory) to place at the top of
Expand All @@ -208,6 +207,6 @@

# Add mappings
intersphinx_mapping = {
'urllib3': ('http://urllib3.readthedocs.org/en/latest', None),
'python': ('http://docs.python.org/3', None),
"urllib3": ("http://urllib3.readthedocs.org/en/latest", None),
"python": ("http://docs.python.org/3", None),
}
2 changes: 1 addition & 1 deletion dulwich/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def tar_stream(store, tree, mtime, prefix=b"", format=""):

info = tarfile.TarInfo()
# tarfile only works with ascii.
info.name = entry_abspath.decode('utf-8', 'surrogateescape')
info.name = entry_abspath.decode("utf-8", "surrogateescape")
info.size = blob.raw_length()
info.mode = entry.mode
info.mtime = mtime
Expand Down
19 changes: 12 additions & 7 deletions dulwich/bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@


class Bundle:

version: Optional[int] = None

capabilities: Dict[str, str] = {}
Expand All @@ -35,10 +34,12 @@ class Bundle:
pack_data: Union[PackData, Sequence[bytes]] = []

def __repr__(self) -> str:
return (f"<{type(self).__name__}(version={self.version}, "
f"capabilities={self.capabilities}, "
f"prerequisites={self.prerequisites}, "
f"references={self.references})>")
return (
f"<{type(self).__name__}(version={self.version}, "
f"capabilities={self.capabilities}, "
f"prerequisites={self.prerequisites}, "
f"references={self.references})>"
)

def __eq__(self, other):
if not isinstance(other, type(self)):
Expand Down Expand Up @@ -120,9 +121,13 @@ def write_bundle(f, bundle):
if value is not None:
f.write(b"=" + value.encode("utf-8"))
f.write(b"\n")
for (obj_id, comment) in bundle.prerequisites:
for obj_id, comment in bundle.prerequisites:
f.write(b"-%s %s\n" % (obj_id, comment.encode("utf-8")))
for ref, obj_id in bundle.references.items():
f.write(b"%s %s\n" % (obj_id, ref))
f.write(b"\n")
write_pack_data(f.write, num_records=len(bundle.pack_data), records=bundle.pack_data.iter_unpacked())
write_pack_data(
f.write,
num_records=len(bundle.pack_data),
records=bundle.pack_data.iter_unpacked(),
)
67 changes: 34 additions & 33 deletions dulwich/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def run(self, args):
type=str,
help="Retrieve archive from specified remote repo",
)
parser.add_argument('committish', type=str, nargs='?')
parser.add_argument("committish", type=str, nargs="?")
args = parser.parse_args(args)
if args.remote:
client, path = get_transport_and_path(args.remote)
Expand All @@ -84,8 +84,7 @@ def run(self, args):
)
else:
porcelain.archive(
".", args.committish, outstream=sys.stdout.buffer,
errstream=sys.stderr
".", args.committish, outstream=sys.stdout.buffer, errstream=sys.stderr
)


Expand All @@ -108,8 +107,8 @@ def run(self, argv):
class cmd_fetch_pack(Command):
def run(self, argv):
parser = argparse.ArgumentParser()
parser.add_argument('--all', action='store_true')
parser.add_argument('location', nargs='?', type=str)
parser.add_argument("--all", action="store_true")
parser.add_argument("location", nargs="?", type=str)
args = parser.parse_args(argv)
client, path = get_transport_and_path(args.location)
r = Repo(".")
Expand Down Expand Up @@ -139,7 +138,7 @@ class cmd_fsck(Command):
def run(self, args):
opts, args = getopt(args, "", [])
opts = dict(opts)
for (obj, msg) in porcelain.fsck("."):
for obj, msg in porcelain.fsck("."):
print(f"{obj}: {msg}")


Expand Down Expand Up @@ -175,13 +174,14 @@ def run(self, args):

r = Repo(".")
if args == []:
commit_id = b'HEAD'
commit_id = b"HEAD"
else:
commit_id = args[0]
commit = parse_commit(r, commit_id)
parent_commit = r[commit.parents[0]]
porcelain.diff_tree(
r, parent_commit.tree, commit.tree, outstream=sys.stdout.buffer)
r, parent_commit.tree, commit.tree, outstream=sys.stdout.buffer
)


class cmd_dump_pack(Command):
Expand Down Expand Up @@ -249,9 +249,12 @@ def run(self, args):
"--depth", dest="depth", type=int, help="Depth at which to fetch"
)
parser.add_option(
"-b", "--branch", dest="branch", type=str,
help=("Check out branch instead of branch pointed to by remote "
"HEAD"))
"-b",
"--branch",
dest="branch",
type=str,
help=("Check out branch instead of branch pointed to by remote " "HEAD"),
)
options, args = parser.parse_args(args)

if args == []:
Expand All @@ -265,8 +268,13 @@ def run(self, args):
target = None

try:
porcelain.clone(source, target, bare=options.bare, depth=options.depth,
branch=options.branch)
porcelain.clone(
source,
target,
bare=options.bare,
depth=options.depth,
branch=options.branch,
)
except GitProtocolError as e:
print("%s" % e)

Expand Down Expand Up @@ -307,9 +315,9 @@ def run(self, args):
class cmd_pack_refs(Command):
def run(self, argv):
parser = argparse.ArgumentParser()
parser.add_argument('--all', action='store_true')
parser.add_argument("--all", action="store_true")
# ignored, we never prune
parser.add_argument('--no-prune', action='store_true')
parser.add_argument("--no-prune", action="store_true")

args = parser.parse_args(argv)

Expand All @@ -319,7 +327,7 @@ def run(self, argv):
class cmd_show(Command):
def run(self, argv):
parser = argparse.ArgumentParser()
parser.add_argument('objectish', type=str, nargs='*')
parser.add_argument("objectish", type=str, nargs="*")
args = parser.parse_args(argv)
porcelain.show(".", args.objectish or None)

Expand Down Expand Up @@ -562,12 +570,8 @@ def run(self, args):
idxf = open(basename + ".idx", "wb")
close = [packf, idxf]
porcelain.pack_objects(
".",
object_ids,
packf,
idxf,
deltify=deltify,
reuse_deltas=reuse_deltas)
".", object_ids, packf, idxf, deltify=deltify, reuse_deltas=reuse_deltas
)
for f in close:
f.close()

Expand All @@ -584,17 +588,18 @@ def run(self, args):


class cmd_push(Command):

def run(self, argv):
parser = argparse.ArgumentParser()
parser.add_argument('-f', '--force', action='store_true', help='Force')
parser.add_argument('to_location', type=str)
parser.add_argument('refspec', type=str, nargs='*')
parser.add_argument("-f", "--force", action="store_true", help="Force")
parser.add_argument("to_location", type=str)
parser.add_argument("refspec", type=str, nargs="*")
args = parser.parse_args(argv)
try:
porcelain.push('.', args.to_location, args.refspec or None, force=args.force)
porcelain.push(
".", args.to_location, args.refspec or None, force=args.force
)
except porcelain.DivergedBranches:
sys.stderr.write('Diverged branches; specify --force to override')
sys.stderr.write("Diverged branches; specify --force to override")
return 1


Expand All @@ -606,7 +611,6 @@ def run(self, args):


class SuperCommand(Command):

subcommands: Dict[str, Type[Command]] = {}
default_command: Optional[Type[Command]] = None

Expand All @@ -624,7 +628,6 @@ def run(self, args):


class cmd_remote(SuperCommand):

subcommands = {
"add": cmd_remote_add,
}
Expand All @@ -635,7 +638,7 @@ def run(self, argv):
parser = argparse.ArgumentParser()
parser.parse_args(argv)
for path, sha in porcelain.submodule_list("."):
sys.stdout.write(f' {sha} {path}\n')
sys.stdout.write(f" {sha} {path}\n")


class cmd_submodule_init(Command):
Expand All @@ -646,7 +649,6 @@ def run(self, argv):


class cmd_submodule(SuperCommand):

subcommands = {
"init": cmd_submodule_init,
}
Expand Down Expand Up @@ -699,7 +701,6 @@ def run(self, args):


class cmd_stash(SuperCommand):

subcommands = {
"list": cmd_stash_list,
"pop": cmd_stash_pop,
Expand Down
Loading
Loading