Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

BUG: Inconsistent behavior between `docformatter` and `black`

Abierto
#399 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
58/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
python
Área
tooling

Línea de trabajo

The report shows disagreements across six Python files and includes Black's diffs, but does not identify docformatter's implementation or tests. Start by reproducing with the reported docformatter and Black versions, then inspect how docformatter formats these cases and the project's formatter tests. Done when the reported cases produce output accepted by both tools.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

fresh

Env

Installed tools :

python --version
Python 3.12.7

docformatter --version
docformatter 1.7.8

black --version
black, 26.10.1 (compiled: yes)
Python (CPython) 3.12.7

pyproject.toml :

[tool.docformatter]
wrap-summaries = 88  # --black
wrap-descriptions = 88  # --black
pre-summary-newline = true
close-quotes-on-newline = true

[tool.black]
line-length = 88
target-version = ['py312']
extend-exclude = '''
/(
    assets
)/
'''

Problem

Executions 1 (All code has been formatted by black):
docformatter --check --recursive --black onvif tests docs   
docs\hooks\misc.py
onvif\operator.py
onvif\cli\helpers\products.py
tests\cli\test_cli_helper_wsdl_parser.py
tests\cli\test_cli_interactive_service.py
tests\utilities\test_exceptions.py

black --check .
All done! ✨ 🍰 ✨
179 files would be left unchanged.

For docformatter, code styles that have already been formatted by black are considered to have failed or to be non-compliant with the standards.

Executions 2 (All code has been formatted by docformatter):
docformatter --recursive --black --in-place onvif tests docs

black --check .                                             
would reformat F:\Forks\onvif-python\docs\hooks\misc.py
would reformat F:\Forks\onvif-python\onvif\cli\helpers\products.py
would reformat F:\Forks\onvif-python\onvif\operator.py
would reformat F:\Forks\onvif-python\tests\utilities\test_exceptions.py
would reformat F:\Forks\onvif-python\tests\cli\test_cli_helper_wsdl_parser.py
would reformat F:\Forks\onvif-python\tests\cli\test_cli_interactive_service.py

Oh no! 💥 💔 💥
6 files would be reformatted, 173 files would be left unchanged.

Once all docstrings and code have been formatted by docformatter, now black then considers them unformatted.

Diff for debugging
black --diff docs/hooks/misc.py onvif/operator.py onvif/cli/helpers/products.py tests/utilities/test_exceptions.py tests/cli/test_cli_helper_wsdl_parser.py tests/cli/test_cli_interactive_service.py
--- docs\hooks\misc.py  2026-10-21 19:46:44.117053+00:00
+++ docs\hooks\misc.py  2026-10-21 19:48:41.899862+00:00
@@ -1,6 +1,7 @@
 """Misc Mkdocs hooks."""
+
 
 def on_page_content(html, page, config, files):  # pylint: disable=unused-argument
     """Exclude mkdocstrings source blocks from Material search."""
     return html.replace(
         '<details class="mkdocstrings-source">',
would reformat docs\hooks\misc.py
--- onvif\cli\helpers\products.py       2026-10-21 19:46:44.299099+00:00
+++ onvif\cli\helpers\products.py       2026-10-21 19:48:42.029537+00:00
@@ -24,21 +24,21 @@
     # Get the database path relative to the script location
     db_path = Path(__file__).resolve().parent.parent.parent / "db" / "products.db"
 
     if not os.path.exists(db_path):
         print(
-            f"{colorize('Error:', 'red')} "  f"Products database not found at {db_path}"
+            f"{colorize('Error:', 'red')} " f"Products database not found at {db_path}"
         )
         sys.exit(1)
 
     # Validate pagination parameters
     if page < 1:
         print(f"{colorize('Error:', 'red')} Page number must be 1 or greater")
         sys.exit(1)
 
     if per_page < 1 or per_page > 100:
-        print(f"{colorize('Error:', 'red')} "  "Per-page must be between 1 and 100")
+        print(f"{colorize('Error:', 'red')} " "Per-page must be between 1 and 100")
         sys.exit(1)
 
     try:
         conn = sqlite3.connect(db_path)
         cursor = conn.cursor()
would reformat onvif\cli\helpers\products.py
--- onvif\operator.py   2026-10-21 19:46:44.226079+00:00
+++ onvif\operator.py   2026-10-21 19:48:42.044543+00:00
@@ -87,10 +87,11 @@
     :material-alert-circle:{ .danger } Requires disk I/O and a writable cache directory
 
     !!! bug "Use case"     Production applications, CLI tools, and environments where
     WSDL/XSD caching should persist across restarts.
     """
+
 
 class ONVIFOperator:
     """
     <!-- md:version 0.0.1 --> <!-- md:internal -->
 
would reformat onvif\operator.py
--- tests\utilities\test_exceptions.py  2026-10-21 19:46:45.729424+00:00
+++ tests\utilities\test_exceptions.py  2026-10-21 19:48:42.071102+00:00
@@ -34,22 +34,18 @@
             """exceptions."""
 
             class RequestException(Exception):
                 """RequestException."""
 
-
             class ConnectionError(RequestException):
                 """ConnectionError."""
 
-
             class Timeout(RequestException):
                 """Timeout."""
 
-
             class ReadTimeout(Timeout):
                 """ReadTimeout."""
-
 
     requests = MockRequestsModule()  # type: ignore[assignment]
 
 
 class TestONVIFOperationException:
would reformat tests\utilities\test_exceptions.py
--- tests\cli\test_cli_helper_wsdl_parser.py    2026-10-21 19:46:45.158408+00:00
+++ tests\cli\test_cli_helper_wsdl_parser.py    2026-10-21 19:48:42.138691+00:00
@@ -418,12 +418,11 @@
 
         assert result == "Hello world from parser"
 
     def test_handles_multiline_links(self):
         """Test converting links whose content spans multiple lines."""
-        result = clean_documentation_html(\
-                                          """
+        result = clean_documentation_html("""
             <a href="https://example.com">
                 Example
             </a>
             """)
 
@@ -443,12 +442,11 @@
 
         assert extract_documentation_text(element) == "Hello world"
 
     def test_text_and_children(self):
         """Test extracting text before, inside, and after child elements."""
-        element = etree.fromstring(\
-                                   b"""
+        element = etree.fromstring(b"""
             <documentation>
                 Before
                 <b>middle</b>
                 After
             </documentation>
would reformat tests\cli\test_cli_helper_wsdl_parser.py
--- tests\cli\test_cli_interactive_service.py   2026-10-21 19:46:45.301377+00:00
+++ tests\cli\test_cli_interactive_service.py   2026-10-21 19:48:42.218530+00:00
@@ -734,11 +734,11 @@
                     {
                         "name": "Token",
                         "type": "string",
                         "minOccurs": "1",
                         "maxOccurs": "1",
-                        "documentation": ("First line.\n"  "\n"  "Second line."),
+                        "documentation": ("First line.\n" "\n" "Second line."),
                     }
                 ],
             },
             "output": None,
         }
would reformat tests\cli\test_cli_interactive_service.py
Lenguaje dominante
Python
Estrellas
598
Forks
97
Merge medio
1 d 8 h
PR fusionados (30 d)
11

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de PyCQA/docformatter

Todos los issues de PyCQA/docformatter

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.