koxudaxi / datamodel-code-generator

Pydantic model and dataclasses.dataclass generator for easy conversion of JSON, OpenAPI, JSON Schema, and YAML data sources.
https://koxudaxi.github.io/datamodel-code-generator/
MIT License
2.74k stars 301 forks source link

Black 24.1.0 breaks code formatting if wrap-string-literal is set #1821

Closed airwoodix closed 9 months ago

airwoodix commented 9 months ago

Describe the bug

Black 24.1.0 was just released and removes support for the deprecated --experimental-string-processing flag (psf/black#4096). This breaks the code in format.py that uses this option:

Traceback (most recent call last):
  File ".../python3.11/site-packages/datamodel_code_generator/__main__.py", line 429, in main
    generate(
  File ".../python3.11/site-packages/datamodel_code_generator/__init__.py", line 463, in generate
    results = parser.parse()
              ^^^^^^^^^^^^^^
  File ".../python3.11/site-packages/datamodel_code_generator/parser/base.py", line 1156, in parse
    code_formatter: Optional[CodeFormatter] = CodeFormatter(
                                              ^^^^^^^^^^^^^^
  File ".../python3.11/site-packages/datamodel_code_generator/format.py", line 152, in __init__
    self.black_mode = black.FileMode(
                      ^^^^^^^^^^^^^^^
TypeError: Mode.__init__() got an unexpected keyword argument 'experimental_string_processing'

Expected behavior

No crash.

Version:

Additional context

Possible mitigation:

koxudaxi commented 9 months ago

@airwoodix Thank you for creating the issue. OK, we should fix it.