Skip to content

Commit

Permalink
style: Format
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Jan 16, 2025
1 parent 23bbbf6 commit 0d71c2f
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion scripts/insiders.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
def human_readable_amount(amount: int) -> str: # noqa: D103
str_amount = str(amount)
if len(str_amount) >= 4: # noqa: PLR2004
return f"{str_amount[:len(str_amount)-3]},{str_amount[-3:]}"
return f"{str_amount[: len(str_amount) - 3]},{str_amount[-3:]}"
return str_amount


Expand Down
10 changes: 4 additions & 6 deletions src/_griffe/docstrings/google.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ def _read_block_items(docstring: Docstring, *, offset: int, **options: Any) -> _
docstring_warning(
docstring,
new_offset,
f"Confusing indentation for continuation line {new_offset+1} in docstring, "
f"should be {indent} * 2 = {indent*2} spaces, not {cont_indent}",
f"Confusing indentation for continuation line {new_offset + 1} in docstring, "
f"should be {indent} * 2 = {indent * 2} spaces, not {cont_indent}",
)

elif line.startswith(indent * " "):
Expand Down Expand Up @@ -201,8 +201,7 @@ def _read_parameters(
if " " in name_with_type:
name, annotation = name_with_type.split(" ", 1)
annotation = annotation.strip("()")
if annotation.endswith(", optional"):
annotation = annotation[:-10]
annotation = annotation.removesuffix(", optional")
# try to compile the annotation to transform it into an expression
annotation = parse_docstring_annotation(annotation, docstring)
else:
Expand Down Expand Up @@ -280,8 +279,7 @@ def _read_attributes_section(
if " " in name_with_type:
name, annotation = name_with_type.split(" ", 1)
annotation = annotation.strip("()")
if annotation.endswith(", optional"):
annotation = annotation[:-10]
annotation = annotation.removesuffix(", optional")
# try to compile the annotation to transform it into an expression
annotation = parse_docstring_annotation(annotation, docstring)
else:
Expand Down
2 changes: 1 addition & 1 deletion src/_griffe/docstrings/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def _read_block_items(
docstring_warning(
docstring,
new_offset,
f"Confusing indentation for continuation line {new_offset+1} in docstring, "
f"Confusing indentation for continuation line {new_offset + 1} in docstring, "
f"should be 4 spaces, not {cont_indent}",
)

Expand Down
2 changes: 1 addition & 1 deletion src/_griffe/docstrings/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def warn(docstring: Docstring, offset: int, message: str, log_level: LogLevel =
except BuiltinModuleError:
prefix = f"<module: {docstring.parent.module.name}>" # type: ignore[union-attr]
log = getattr(logger, log_level.value)
log(f"{prefix}:{(docstring.lineno or 0)+offset}: {message}")
log(f"{prefix}:{(docstring.lineno or 0) + offset}: {message}")

warn(docstring, offset, message, log_level)

Expand Down
5 changes: 2 additions & 3 deletions src/_griffe/finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,7 @@ def find_package(self, module_name: str) -> Package | NamespacePackage:
]

real_module_name = module_name
if real_module_name.endswith("-stubs"):
real_module_name = real_module_name[:-6]
real_module_name = real_module_name.removesuffix("-stubs")
namespace_dirs = []
for path in self.search_paths:
path_contents = self._contents(path)
Expand Down Expand Up @@ -462,7 +461,7 @@ def _handle_pth_file(path: Path) -> list[_SP]:
for line in text.strip().replace(";", "\n").splitlines(keepends=False):
line = line.strip() # noqa: PLW2901
if _re_import_line.match(line):
editable_module = path.parent / f"{line[len('import'):].lstrip()}.py"
editable_module = path.parent / f"{line[len('import') :].lstrip()}.py"
with suppress(UnhandledEditableModuleError):
return _handle_editable_module(editable_module)
if line and not line.startswith("#") and os.path.exists(line): # noqa: PTH110
Expand Down

0 comments on commit 0d71c2f

Please sign in to comment.