Skip to content

Commit

Permalink
Updated black, but be liberal in the dependency setting
Browse files Browse the repository at this point in the history
Projects implementing docstrfmt may already be relying
on the black formatter, but we should try as much as
possible to not interfere with their dependency.
  • Loading branch information
nemesifier committed Jul 29, 2024
1 parent 05474b5 commit 3b1eedf
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 12 deletions.
12 changes: 7 additions & 5 deletions docstrfmt/docstrfmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,11 @@ def _format_children(
self, node: docutils.nodes.Node, context
) -> Iterator[Iterator[str]]:
return (
self.manager.perform_format(child, context)
if index == 0
else self.manager.perform_format(child, context.wrap_first_at(0))
(
self.manager.perform_format(child, context)
if index == 0
else self.manager.perform_format(child, context.wrap_first_at(0))
)
for index, child in enumerate(node.children)
)

Expand Down Expand Up @@ -893,8 +895,8 @@ def reference(
None, chain(self._format_children(node, context)), context, node.line
)
)
anonymous_suffix: Callable[[bool], str] = (
lambda anonymous: "__" if anonymous else "_"
anonymous_suffix: Callable[[bool], str] = lambda anonymous: (
"__" if anonymous else "_"
)
attributes = node.attributes # type: ignore
children = node.children # type: ignore
Expand Down
4 changes: 2 additions & 2 deletions docstrfmt/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,8 @@ def _format_file(
raw_output = True
reporter.print(f"Checking {file}", 2)
misformatted = False
with nullcontext(sys.stdin) if file.name == "-" else open(
file, encoding="utf-8"
with (
nullcontext(sys.stdin) if file.name == "-" else open(file, encoding="utf-8")
) as f:
input_string = f.read()
newline = getattr(f, "newlines", None)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
},
extras_require=extras_requires,
install_requires=[
"black==23.*",
"black>=23.0.0,<=25.0.0",
"click==8.*",
"docutils==0.20.*",
"libcst==1.*",
Expand Down
1 change: 1 addition & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""docstrfmt Test Suite."""

import black
import docutils.nodes

Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Prepare py.test."""

import os
import shutil

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""This is an example python file"""


test = "value"


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""This is an example python file"""


test = "value"


Expand Down
1 change: 0 additions & 1 deletion tests/test_files/error_files/py_file_error_invalid_rst.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""This is an example python file"""


test = "value"


Expand Down
1 change: 0 additions & 1 deletion tests/test_files/py_file.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""This is an example python file"""


test = "value"


Expand Down

0 comments on commit 3b1eedf

Please sign in to comment.