diff --git a/CHANGES.rst b/CHANGES.rst index b8421ca3d..903134d61 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -58,6 +58,7 @@ Internal - No need to use `typing.Pattern` instead of `re.Pattern` in Python 3.9+. - Always use newest artifact upload/download actions from the v4 series in the CI build. - Use `datetime.datetime.now()`, not ``.utcnow()`` to silence a deprecation warning. +- Suppress logging about Flynt unless Flynt is enabled. 2.1.1_ - 2024-04-16 diff --git a/src/darker/__main__.py b/src/darker/__main__.py index 43d80a7e6..3689a0e82 100644 --- a/src/darker/__main__.py +++ b/src/darker/__main__.py @@ -209,11 +209,6 @@ def _reformat_and_flynt_single_file( # noqa: PLR0913 relative_path_in_rev2, exclude.flynt, edited_linenums_differ, rev2_isorted ) has_fstring_changes = fstringified != rev2_isorted - logger.debug( - "Flynt resulted in %s lines, with %s changes from fstringification", - len(fstringified.lines), - "some" if has_fstring_changes else "no", - ) # 3. run the code re-formatter on the isorted and fstringified contents of each # edited to-file formatted = _maybe_reformat_single_file( @@ -279,7 +274,13 @@ def _maybe_flynt_single_file( if glob_any(relpath_in_rev2, exclude): # `--flynt` option not specified, don't reformat return rev2_isorted - return apply_flynt(rev2_isorted, relpath_in_rev2, edited_linenums_differ) + result = apply_flynt(rev2_isorted, relpath_in_rev2, edited_linenums_differ) + logger.debug( + "Flynt resulted in %s lines, with %s changes from fstringification", + len(result.lines), + "some" if result != rev2_isorted else "no", + ) + return result def _maybe_reformat_single_file(