From 42610a888a28f61e17f4b736f37a6025b2e63612 Mon Sep 17 00:00:00 2001 From: Antti Kaihola <13725+akaihola@users.noreply.github.com> Date: Thu, 8 Aug 2024 23:24:34 +0300 Subject: [PATCH 1/2] fix: windows py38/py39 relative path issue --- src/darker/__main__.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/darker/__main__.py b/src/darker/__main__.py index 252e74a7b..195d5f78a 100644 --- a/src/darker/__main__.py +++ b/src/darker/__main__.py @@ -52,7 +52,7 @@ from darkgraylib.highlighting import colorize, should_use_color from darkgraylib.log import setup_logging from darkgraylib.main import resolve_paths -from darkgraylib.utils import GIT_DATEFORMAT, DiffChunk, TextDocument +from darkgraylib.utils import GIT_DATEFORMAT, WINDOWS, DiffChunk, TextDocument from graylint.linting import run_linters logger = logging.getLogger(__name__) @@ -561,9 +561,18 @@ def main( # noqa: C901,PLR0912,PLR0915 msg = f"Path(s) {missing_reprs} do not exist in {rev2_repr}" raise FileNotFoundError(msg) + common_root_ = ( + # On Windows, Python <= 3.9 requires the `filter_python_files` `root` argument + # to be an absolute path. Remove this after dropping support for Python 3.9. + # See https://github.com/python/cpython/issues/82852 + common_root.resolve() + if WINDOWS and sys.version_info < (3, 10) + else common_root + ) # These paths are relative to `common_root`: - files_to_process = filter_python_files(paths, common_root, {}) - files_to_blacken = filter_python_files(paths, common_root, black_config) + files_to_process = filter_python_files(paths, common_root_, {}) + files_to_blacken = filter_python_files(paths, common_root_, black_config) + # Now decide which files to reformat (Black & isort). Note that this doesn't apply # to linting. if output_mode == OutputMode.CONTENT or revrange.rev2 == STDIN: From b60ff62742907199f9585e7fb20f819bb2cd575c Mon Sep 17 00:00:00 2001 From: Antti Kaihola <13725+akaihola@users.noreply.github.com> Date: Tue, 27 Aug 2024 23:47:46 +0300 Subject: [PATCH 2/2] docs: update the change log --- CHANGES.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 141a7510d..a5fd39f27 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -23,6 +23,8 @@ Fixed - Pass Graylint version to `~darkgraylib.command_line.make_argument_parser` to make ``--version`` display the correct version number. - Pass full environment to Git to avoid the "dubious ownership" error. +- Work around a `pathlib.Path.resolve` bug in Python 3.8 and 3.9 on Windows. + The work-around should be removed when Python 3.8 and 3.9 are no longer supported. 2.1.1_ - 2024-04-16