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 v22.1.0 ? #264

Closed
jedie opened this issue Jan 30, 2022 · 15 comments · Fixed by #270
Closed

incompatible with black v22.1.0 ? #264

jedie opened this issue Jan 30, 2022 · 15 comments · Fixed by #270

Comments

@jedie
Copy link
Contributor

jedie commented Jan 30, 2022

$ poetry run darker .
Traceback (most recent call last):
  File "/home/jens/repos/dev-shell/.venv/bin/darker", line 8, in <module>
    sys.exit(main_with_error_handling())
  File "/home/jens/repos/dev-shell/.venv/lib/python3.9/site-packages/darker/__main__.py", line 421, in main_with_error_handling
    return main()
  File "/home/jens/repos/dev-shell/.venv/lib/python3.9/site-packages/darker/__main__.py", line 312, in main
    args, config, config_nondefault = parse_command_line(argv)
  File "/home/jens/repos/dev-shell/.venv/lib/python3.9/site-packages/darker/command_line.py", line 107, in parse_command_line
    config = load_config(args.src)
  File "/home/jens/repos/dev-shell/.venv/lib/python3.9/site-packages/darker/config.py", line 107, in load_config
    path = find_project_root(tuple(srcs or ["."])) / "pyproject.toml"
TypeError: unsupported operand type(s) for /: 'tuple' and 'str'

black changed the return value of find_project_root() here: psf/black@521d1b8#diff-1a5882c84fe4b3f18199a3e021822c1ea4bdc3f86952ea450c4db15d9387c7c3

It's not a tuple :(

@jedie jedie changed the title incobatilbe with black v22.1.0 ? incompatible with black v22.1.0 ? Jan 30, 2022
@foxwhite25
Copy link

Can comfirm with my project action

Run akaihola/[email protected]
Run # Exists since using github.action_path + path to main script doesn't work
Traceback (most recent call last):
  File "/home/runner/work/_actions/akaihola/darker/github-action-v1.3.2-2/.darker-env/bin/darker", line 8, in <module>
    sys.exit(main_with_error_handling())
  File "/home/runner/work/_actions/akaihola/darker/github-action-v1.3.2-2/.darker-env/lib/python3.8/site-packages/darker/__main__.py", line 421, in main_with_error_handling
    return main()
  File "/home/runner/work/_actions/akaihola/darker/github-action-v1.3.2-2/.darker-env/lib/python3.8/site-packages/darker/__main__.py", line 312, in main
    args, config, config_nondefault = parse_command_line(argv)
  File "/home/runner/work/_actions/akaihola/darker/github-action-v1.3.2-2/.darker-env/lib/python3.8/site-packages/darker/command_line.py", line 107, in parse_command_line
    config = load_config(args.src)
  File "/home/runner/work/_actions/akaihola/darker/github-action-v1.3.2-2/.darker-env/lib/python3.8/site-packages/darker/config.py", line 107, in load_config
    path = find_project_root(tuple(srcs or ["."])) / "pyproject.toml"
TypeError: unsupported operand type(s) for /: 'tuple' and 'str'
Error: Process completed with exit code 1.

@akaihola
Copy link
Owner

akaihola commented Feb 2, 2022

This will be fixed in #270.

@mayk0gan
Copy link
Collaborator

mayk0gan commented Feb 5, 2022

is there some workaround in the meanwhile?
I use darker's github action from the master branch (as suggested here)

@jedie
Copy link
Contributor Author

jedie commented Feb 5, 2022

I just pin black as a work-a-round:

darker = "*"
black = "==21.12b0"

@mayk0gan
Copy link
Collaborator

mayk0gan commented Feb 6, 2022

I just pin black as a work-a-round:

darker = "*"
black = "==21.12b0"

I'm not sure that it would work with the github action. Do you put it in pyproject.yaml?

@mayk0gan
Copy link
Collaborator

mayk0gan commented Feb 6, 2022

The github action still doesn't work on master though:

Traceback (most recent call last):
  File "/home/runner/work/_actions/akaihola/darker/master/.darker-env/bin/darker", line 8, in <module>
    sys.exit(main_with_error_handling())
  File "/home/runner/work/_actions/akaihola/darker/master/.darker-env/lib/python3.8/site-packages/darker/__main__.py", line [42](https://github.com/sentraio/sentra-discovery/runs/5085406006?check_suite_focus=true#step:4:42)1, in main_with_error_handling
    return main()
  File "/home/runner/work/_actions/akaihola/darker/master/.darker-env/lib/python3.8/site-packages/darker/__main__.py", line 312, in main
    args, config, config_nondefault = parse_command_line(argv)
  File "/home/runner/work/_actions/akaihola/darker/master/.darker-env/lib/python3.8/site-packages/darker/command_line.py", line 107, in parse_command_line
    config = load_config(args.src)
  File "/home/runner/work/_actions/akaihola/darker/master/.darker-env/lib/python3.8/site-packages/darker/config.py", line 107, in load_config
    path = find_project_root(tuple(srcs or ["."])) / "pyproject.toml"
TypeError: unsupported operand type(s) for /: 'tuple' and 'str'
Error: Process completed with exit code 1.

@akaihola
Copy link
Owner

akaihola commented Feb 8, 2022

@mayk0gan I think it still clones the last release when building the image even though the action "recipe" comes from master. Should be fixed when we release 1.4.0.

@foxwhite25
Copy link

foxwhite25 commented Feb 9, 2022

It still failed with a @1.4.0 to specify 1.4.0, thats odd.

Run # Exists since using github.action_path + path to main script doesn't work
Traceback (most recent call last):
  File "/home/runner/work/_actions/akaihola/darker/1.4.0/.darker-env/bin/darker", line 8, in <module>
    sys.exit(main_with_error_handling())
  File "/home/runner/work/_actions/akaihola/darker/1.4.0/.darker-env/lib/python3.8/site-packages/darker/__main__.py", line [42](https://github.com/foxwhite25/qq.py/runs/5121125995?check_suite_focus=true#step:3:42)1, in main_with_error_handling
    return main()
  File "/home/runner/work/_actions/akaihola/darker/1.4.0/.darker-env/lib/python3.8/site-packages/darker/__main__.py", line 312, in main
    args, config, config_nondefault = parse_command_line(argv)
  File "/home/runner/work/_actions/akaihola/darker/1.4.0/.darker-env/lib/python3.8/site-packages/darker/command_line.py", line 107, in parse_command_line
    config = load_config(args.src)
  File "/home/runner/work/_actions/akaihola/darker/1.4.0/.darker-env/lib/python3.8/site-packages/darker/config.py", line 107, in load_config
    path = find_project_root(tuple(srcs or ["."])) / "pyproject.toml"
TypeError: unsupported operand type(s) for /: 'tuple' and 'str'
Error: Process completed with exit code 1.```

@jenshnielsen
Copy link

@foxwhite25 the action has a version setting that defaults to 1.3.2 you probably need to explicitly set that to 1.4.0 https://github.com/akaihola/darker/blob/master/action.yml#L18

@akaihola
Copy link
Owner

akaihola commented Feb 9, 2022

Thanks @mayk0gan @foxwhite25 @jenshnielsen, I'll look into this soon. Is this the same as #260?

@jenshnielsen
Copy link

jenshnielsen commented Feb 9, 2022

I have set it with the following config which seems to work fine.
But note that I need to set the version twice

name: Lint with Darker

 on: [push, pull_request]

 jobs:
   lint-with-darker:
     runs-on: ubuntu-latest
     steps:
       - uses: actions/checkout@v2
         with:
           fetch-depth: 0
       - uses: akaihola/[email protected]
         with:
           options: "--check --diff -r origin/master -i"
           version: "1.4.0"

@MatthijsBurgh
Copy link
Collaborator

As mentioned in @260. The action file still sets 1.3.2 as the darker version to be used. Even in master and the 1.4.0 tag. So a manual override is still needed at the moment. But this should be fixed in the action file.

@jedie
Copy link
Contributor Author

jedie commented Feb 11, 2022

I made this:

    - uses: actions/checkout@v2
      with:
        fetch-depth: 0
    - name: 'fetch master'
      run: |
        git fetch origin master

https://github.com/boxine/django-huey-monitor/blob/49d5b214afa1f0af0b8e7fb9b24f92327c8ad5be/.github/workflows/pythonapp.yml#L24-L29

to always compare with master ;)

@jenshnielsen
Copy link

@jedie I originally started with --check --diff -r master but realized that using --check --diff -r origin/master I did not need to explicitly fetch the master branch

jedie added a commit to boxine/django-huey-monitor that referenced this issue Feb 11, 2022
Try to remove fetch master, see: akaihola/darker#264 (comment)
@jedie
Copy link
Contributor Author

jedie commented Feb 11, 2022

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