Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatible with black-22.10.1.dev19+gffaaf48 and later #403

Closed
akaihola opened this issue Nov 13, 2022 · 3 comments · Fixed by #404
Closed

Incompatible with black-22.10.1.dev19+gffaaf48 and later #403

akaihola opened this issue Nov 13, 2022 · 3 comments · Fixed by #404
Assignees
Labels
bug Something isn't working
Milestone

Comments

@akaihola
Copy link
Owner

Describe the bug
Unit tests fail if psf/black@ffaaf48 or later is installed.

To Reproduce
Steps to reproduce the behavior:

  1. In a fresh virtualenv, pip install 'darker[test]==1.5.1' git+https://github.com/psf/black.git@ffaaf48
  2. In a Git working tree of a Python repository, run Darker with darker
  3. See error

Expected behavior
Darker should run successfully and reformat modified regions of Python fules.

Screenshots

Traceback (most recent call last):
  File "bin/darker", line 8, in <module>
    sys.exit(main_with_error_handling())
  File "darker/__main__.py", line 486, in main_with_error_handling
    return main()
  File "darker/__main__.py", line 423, in main
    files_to_process = filter_python_files(paths, root, {})
  File "darker/black_diff.py", line 142, in filter_python_files
    gen_python_files(
TypeError: gen_python_files() got an unexpected keyword argument 'gitignore'

Environment (please complete the following information):

  • OS: NixOS 22.05
  • Python version: 3.9.13
  • Git version: 2.36.2
  • Darker version: 1.5.1
  • Black version: commit ffaaf48

Additional context
psf/black@ffaaf48 replaces the gitignore: Optional[PathSpec] argument of black.files.gen_python_files() with gitignore_dict: Optional[Dict[Path, PathSpec]].

Before that commit, gitignore is used like:

        # First ignore files matching .gitignore, if passed
        if gitignore is not None and gitignore.match_file(normalized_path):
            report.path_ignored(child, "matches the .gitignore file content")
            continue

And after the commit, gitignore_dict like:

        # First ignore files matching .gitignore, if passed
        if gitignore_dict and path_is_ignored(child, gitignore_dict, report):
            continue

# [...]

        if child.is_dir():
            # If gitignore is None, gitignore usage is disabled, while a Falsey
            # gitignore is when the directory doesn't have a .gitignore file.
            if gitignore_dict is not None:
                new_gitignore_dict = {
                    **gitignore_dict,
                    root / child: get_gitignore(child),
                }
            else:
                new_gitignore_dict = None

# [then passing `new_gitignore_dict` back to the same function
@soxofaan
Copy link
Contributor

Any chance on a darker release in near future including fix for this issue?
I'm running darker in GitHub Action through pre-commit, and now I have to manually pin down black<22.12.0 to keep that working

(thanks for darker by the way, great tool, I use it all the time)

@soxofaan
Copy link
Contributor

An out-of-the-box pipx install of darker is also broken at the moment.

Workaround is to use pipx inject to downgrade black:

pipx inject darker 'black<22.12.0'

@akaihola
Copy link
Owner Author

@soxofaan, thanks for appreciation! Darker 1.6.0 with a fix for this has now been released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants