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

Latest version of Black (22.12.0) breaks Darker #412

Closed
wpnbos opened this issue Dec 12, 2022 · 7 comments
Closed

Latest version of Black (22.12.0) breaks Darker #412

wpnbos opened this issue Dec 12, 2022 · 7 comments

Comments

@wpnbos
Copy link

wpnbos commented Dec 12, 2022

22.12.0 (exception occurs):

(venv) william@Sonic ml % pip install black black==22.12.0
Requirement already satisfied: black in ./venv/lib/python3.9/site-packages (22.8.0)
Collecting black
  Downloading black-22.12.0-py3-none-any.whl (167 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 167.3/167.3 kB 5.2 MB/s eta 0:00:00
Requirement already satisfied: platformdirs>=2 in ./venv/lib/python3.9/site-packages (from black) (2.5.2)
Requirement already satisfied: pathspec>=0.9.0 in ./venv/lib/python3.9/site-packages (from black) (0.10.1)
Requirement already satisfied: tomli>=1.1.0 in ./venv/lib/python3.9/site-packages (from black) (2.0.1)
Requirement already satisfied: mypy-extensions>=0.4.3 in ./venv/lib/python3.9/site-packages (from black) (0.4.3)
Requirement already satisfied: click>=8.0.0 in ./venv/lib/python3.9/site-packages (from black) (8.1.3)
Requirement already satisfied: typing-extensions>=3.10.0.0 in ./venv/lib/python3.9/site-packages (from black) (4.3.0)
Installing collected packages: black
  Attempting uninstall: black
    Found existing installation: black 22.8.0
    Uninstalling black-22.8.0:
      Successfully uninstalled black-22.8.0
Successfully installed black-22.12.0
(venv) william@Sonic ml % darker
Traceback (most recent call last):
  File "/Users/william/Documents/unetiq/order-link/ml/venv/bin/darker", line 8, in <module>
    sys.exit(main_with_error_handling())
  File "/Users/william/Documents/unetiq/order-link/ml/venv/lib/python3.9/site-packages/darker/__main__.py", line 486, in main_with_error_handling
    return main()
  File "/Users/william/Documents/unetiq/order-link/ml/venv/lib/python3.9/site-packages/darker/__main__.py", line 423, in main
    files_to_process = filter_python_files(paths, root, {})
  File "/Users/william/Documents/unetiq/order-link/ml/venv/lib/python3.9/site-packages/darker/black_diff.py", line 142, in filter_python_files
    gen_python_files(
TypeError: gen_python_files() got an unexpected keyword argument 'gitignore'

22.8.0 (works fine):

(venv) william@Sonic ml % pip install black black==22.8.0 
Requirement already satisfied: black in ./venv/lib/python3.9/site-packages (22.12.0)
Collecting black
  Using cached black-22.8.0-cp39-cp39-macosx_11_0_arm64.whl (1.2 MB)
Requirement already satisfied: platformdirs>=2 in ./venv/lib/python3.9/site-packages (from black) (2.5.2)
Requirement already satisfied: click>=8.0.0 in ./venv/lib/python3.9/site-packages (from black) (8.1.3)
Requirement already satisfied: typing-extensions>=3.10.0.0 in ./venv/lib/python3.9/site-packages (from black) (4.3.0)
Requirement already satisfied: pathspec>=0.9.0 in ./venv/lib/python3.9/site-packages (from black) (0.10.1)
Requirement already satisfied: mypy-extensions>=0.4.3 in ./venv/lib/python3.9/site-packages (from black) (0.4.3)
Requirement already satisfied: tomli>=1.1.0 in ./venv/lib/python3.9/site-packages (from black) (2.0.1)
Installing collected packages: black
  Attempting uninstall: black
    Found existing installation: black 22.12.0
    Uninstalling black-22.12.0:
      Successfully uninstalled black-22.12.0
Successfully installed black-22.8.0
(venv) william@Sonic ml % darker
Skipping .ipynb files as Jupyter dependencies are not installed.
You can fix this by running ``pip install black[jupyter]``
(venv) william@Sonic ml % 
@k-dominik
Copy link

also ran into it, see #403

is there any timeline for a new darker version or an obvious way to pin the black version in the darker action?

@victorcui96
Copy link

yeah it'd be great if darker allows customization of the version of black used. I don't see it under the configuration options.

@jedie
Copy link
Contributor

jedie commented Dec 13, 2022

I add black!=22.12.0 in my requirements... But i also think: Darker should set the black version, isn't it?

@victorcui96
Copy link

how do I downgrade the version of black that darker uses in my git pre-commit hook? My pre-commit-config.yaml looks like

repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v2.3.0
    hooks:
      - id: check-yaml
      - id: end-of-file-fixer
      - id: trailing-whitespace
  - repo: https://github.com/akaihola/darker
    rev: 1.5.1
    hooks:
      - id: darker
        args:
           - --line-length=120
        language_version: python3

and I have black!=22.12.0 in my requirements.txt but I'm still getting the gen_python_files() type error.

@leej3
Copy link

leej3 commented Dec 14, 2022

@victorcui96, I think each pre-commit hook installs into its own environment so modifying your project's requirements.txt will have no effect. The above referencing issue has a fix though, so applying that in your pre commit config would look like:

  - repo: https://github.com/akaihola/darker
    rev: 1.5.1
    hooks:
      - id: darker
        args:
           - --line-length=120
        language_version: python3
        additional_dependencies: [black==22.10.0]

@victorcui96
Copy link

@leej3 thanks for that! I didn't know each pre-commit hook installs in its own environment. I changed to

  - repo: https://github.com/akaihola/darker
    rev: 1.5.1
    hooks:
      - id: darker
        args:
          - --line-length=120
        language_version: python3.11
        additional_dependencies:
          - black==22.8.0

and it worked.

@akaihola
Copy link
Owner

This has been fixed in Darker 1.6.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

6 participants