Skip to content

Commit

Permalink
fix: windows py38/py39 relative path issue
Browse files Browse the repository at this point in the history
  • Loading branch information
akaihola committed Aug 9, 2024
1 parent 1afd2d3 commit 475e577
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/darker/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down Expand Up @@ -559,9 +559,16 @@ 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://bugs.python.org/issue38671
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:
Expand Down

0 comments on commit 475e577

Please sign in to comment.