Skip to content

Commit 25fc602

Browse files
committed
Fix up docstring formatting.
1 parent 862b5f6 commit 25fc602

11 files changed

+19
-20
lines changed

gdbmongo/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# limitations under the License.
1515
###
1616
"""The gdbmongo package contains GDB pretty printers and commands for debugging the MongoDB Server.
17+
1718
Its primary target audience is MongoDB employees.
1819
"""
1920

gdbmongo/abseil_printers.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ def gdb_resolve_type(typ: gdb.Type, /) -> gdb.Type:
2727
"""Look up the name of a C++ type with any typedefs, pointers, and references stripped.
2828
2929
This function is useful in contexts where template arguments can be pointers because GDB may not
30-
load the fields of the templated entity otherwise."""
31-
30+
load the fields of the templated entity otherwise.
31+
"""
3232
typ = typ.strip_typedefs()
3333

3434
while typ.code in (gdb.TYPE_CODE_PTR, gdb.TYPE_CODE_REF):
@@ -44,7 +44,6 @@ def AbslHashContainerIterator(container: gdb.Value, /) -> typing.Iterator[gdb.Va
4444
"""Return a generator of every node in the given absl::container_internal::raw_hash_set or
4545
derived class.
4646
"""
47-
4847
capacity = int(container["capacity_"])
4948
ctrl = container["ctrl_"]
5049
slots = container["slots_"]

gdbmongo/decorable_printer.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ class DecorationContainerPrinter(PrettyPrinterProtocol, SupportsDisplayHint):
4040
# pylint: disable=missing-function-docstring
4141
"""Pretty-printer for mongo::DecorationContainer<DecoratedType>.
4242
43-
This includes MongoDB types like ServiceContext, Client, and OperationContext."""
43+
This includes MongoDB types like ServiceContext, Client, and OperationContext.
44+
"""
4445

4546
symbol_name_regexp = re.compile(r"^(.*) in ")
4647
type_name_regexp = re.compile(r"^(.*[\w>])([\s\*]*)$")

gdbmongo/detect_toolchain.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
class ToolchainInfo(typing.NamedTuple):
2929
"""Info about the MongoDB toolchain used to compile an executable."""
30+
3031
compiler: typing.Optional[str]
3132
libstdcxx_python_home: typing.Optional[pathlib.Path]
3233

@@ -51,8 +52,8 @@ def readelf(cls, executable: StrOrBytesPath, /) -> bytes:
5152
"""Return the ELF .comment section of the executable.
5253
5354
The ELF .comment section contains information about which compiler(s) were used in building
54-
the executable."""
55-
55+
the executable.
56+
"""
5657
with tempfile.NamedTemporaryFile() as output_file:
5758
result = subprocess.run(
5859
[cls.objcopy, "--dump-section", f".comment={str(output_file.name)}", executable],
@@ -76,8 +77,8 @@ def parse_gcc_version(
7677
"""Extract the GCC compiler version from the ELF .comment section text.
7778
7879
It is expected for a GCC compiler version to be listed due to the use of libstdc++ in all
79-
MongoDB binaries."""
80-
80+
MongoDB binaries.
81+
"""
8182
if (match := cls.gcc_version_regexp.search(raw_elf_section)) is not None:
8283
return match.group(1).decode()
8384

@@ -98,8 +99,8 @@ def parse_clang_version(cls, raw_elf_section: bytes, /) -> typing.Optional[str]:
9899
@classmethod
99100
def parse_libstdcxx_python_home(cls, gcc_version: str, /) -> typing.Optional[pathlib.Path]:
100101
"""Return the /opt/mongodbtoolchain/vN/share/gcc-X.Y.Z/python directory associated with a
101-
particular GCC compiler version."""
102-
102+
particular GCC compiler version.
103+
"""
103104
if gcc_version.endswith(" 8.5.0"):
104105
return pathlib.Path("/opt/mongodbtoolchain/v3/share/gcc-8.5.0/python")
105106

gdbmongo/interaction.py

-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ def _import_libstdcxx_printers(executable: str, /, *, register_libstdcxx_printer
3131
MongoDB toolchain the executable was compiled with. Register the imported module on sys.modules
3232
and optionally register the pretty printers with GDB itself, if requested.
3333
"""
34-
3534
detector = ToolchainVersionDetector(executable)
3635
toolchain_info = detector.detect()
3736

@@ -49,7 +48,6 @@ def register_printers(*, essentials: bool = True, stdlib: bool = False, abseil:
4948
The pretty printer collections other than gdbmongo-essentials are defaulted to off to avoid
5049
conflicting with the pretty printers defined in the mongodb/mongo repository.
5150
"""
52-
5351
if essentials:
5452
# It would be weird to not register these pretty printers given the whole purpose of the
5553
# gdbmongo package, but a user can always choose to disable them explicitly so we may as
@@ -76,7 +74,6 @@ def on_user_at_prompt() -> None:
7674
"""Import the libstdc++ GDB pretty printers when either the `attach <pid>` or
7775
`core-file <pathname>` commands are run in GDB.
7876
"""
79-
8077
if (executable := gdb.selected_inferior().progspace.filename) is None:
8178
# The `attach` command would have filled in the filename so we only need to check if
8279
# a core dump has been loaded with the executable file also being loaded.

gdbmongo/lock_manager_printer.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ def gdb_lookup_value(symbol_name: str, /) -> typing.Optional[gdb.Value]:
4444

4545
class ServiceContextDecorationMixin(typing.Protocol):
4646
"""Class to add support for constructing from the global ServiceContext if the subclass already
47-
supports constructing from a ServiceContext explicitly."""
47+
supports constructing from a ServiceContext explicitly.
48+
"""
4849

4950
Decoration = typing.TypeVar("Decoration", bound="ServiceContextDecorationMixin")
5051

@@ -89,7 +90,6 @@ def lookup_resource_name(self, res_id: gdb.Value, /) -> typing.Optional[gdb.Valu
8990
"""Return a gdb.Value containing the database or collection namespace string of the
9091
resource.
9192
"""
92-
9393
iterator = stdlib_printers.StdMapPrinter("std::map", self.resources).children()
9494
for ((_, iter_res_id), (_, iter_nss_set)) in zip(iterator, iterator):
9595
if iter_res_id == res_id:

gdbmongo/stdlib_printers_loader.py

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ def resolve_import(toolchain_info: gdbmongo.detect_toolchain.ToolchainInfo,
3737
the 0-argument function will NOT have registered the pretty printers with GDB itself. The caller
3838
must take care to call register_libstdcxx_printers() on the returned module object.
3939
"""
40-
4140
if (libstdcxx_python_home := toolchain_info.libstdcxx_python_home) is None:
4241
raise ValueError("Unable to import libstdc++ GDB pretty printers")
4342

stubs/gdb/_type.pyi

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import typing
2121

2222
class TypeCode(enum.IntEnum):
2323
"""https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gdb/gdbtypes.h;hb=refs/tags/gdb-8.3.1-release#l90"""
24+
2425
TYPE_CODE_BITSTRING = -1
2526
TYPE_CODE_PTR = 1
2627
TYPE_CODE_ARRAY = 2

stubs/gdb/printing.pyi

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
###
1616
"""https://sourceware.org/gdb/onlinedocs/gdb/Pretty-Printing-API.html
1717
https://sourceware.org/gdb/onlinedocs/gdb/Writing-a-Pretty_002dPrinter.html
18-
https://sourceware.org/gdb/onlinedocs/gdb/gdb_002eprinting.html"""
18+
https://sourceware.org/gdb/onlinedocs/gdb/gdb_002eprinting.html
19+
"""
1920

2021
import typing
2122

tests/test_formatting.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ def find_pyfiles() -> typing.Iterator[pathlib.Path]:
3636
def run_yapf(fix: bool) -> bool:
3737
"""Return True if YAPF reports no further changes are needed, and return False otherwise.
3838
39-
This function always returns True when fix == True."""
39+
This function always returns True when fix == True.
40+
"""
4041
# We import the module here to suppress the PendingDeprecationWarning.
4142
# pylint: disable-next=import-outside-toplevel
4243
import yapf

tests/test_stdlib_printers.py

-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ def test_can_load_module_from_toolchain(toolchain_info: ToolchainInfo) -> None:
5858
"""Check that the gdb.libstdcxx.v6 package can be loaded without error for the corresponding
5959
version of the MongoDB toolchain.
6060
"""
61-
6261
(module, _register_module) = resolve_import(toolchain_info)
6362
assert module.register_libstdcxx_printers is not None
6463

@@ -72,7 +71,6 @@ def test_can_import_module_after_registering(self) -> None:
7271
"""Check that the gdb.libstdcxx.v6 module is only available to import after the returned
7372
register_module() function has been called.
7473
"""
75-
7674
(_module, register_module) = resolve_import(self.toolchain_info)
7775
assert "gdb.libstdcxx.v6" not in sys.modules
7876
assert "gdb.libstdcxx.v6.printers" not in sys.modules

0 commit comments

Comments
 (0)