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

The repo for black has changed locations #270

Closed
baileythegreen opened this issue May 25, 2021 · 8 comments · Fixed by #271
Closed

The repo for black has changed locations #270

baileythegreen opened this issue May 25, 2021 · 8 comments · Fixed by #271
Assignees
Labels
bug something isn't working how it should
Projects

Comments

@baileythegreen
Copy link
Contributor

baileythegreen commented May 25, 2021

Summary:

The .pre-commit-config.yaml file contains an old URL for black. This did not cause a problem for me when running black from the command line, but when attempting to commit from within atom, I got this error:

[WARNING] The 'rev' field of repo 'https://github.com/ambv/black' appears to be a mutable reference (moving tag / branch). Mutable references are never updated after first install and are not supported. See https://pre-commit.com/#using-the-latest-version-for-a-repository for more details.

Changing the URL in the pre-commit file from https://github.com/ambv/black to https://github.com/psf/black
(which the former now redirects to) resolved the problem. — I have done this only for the fastANI branch, so far.

Reproducible Steps:

I'm unclear if this issue is likely to be common, or if it relies upon my specific setup.

Python Version:

I think atom is running 3.8.

Operating System:

MacOS 10.13.6

@widdowquinn widdowquinn added the bug something isn't working how it should label May 27, 2021
@widdowquinn widdowquinn added this to To do in pyani via automation May 27, 2021
@widdowquinn
Copy link
Owner

Since we provide the .pre-commit-config.yaml file as an aid to developers, we really should fix this. I'll get on it.

@widdowquinn
Copy link
Owner

The solution looks to be a little different to that proposed.

The warning comes from the rev: tag - this was advised in the black/pre-commit (I forget which) documentation to point to stable - a mutable reference that ought to point at a specific revision/release. That doesn't work for black, as noted in psf/black#420.

So, as indicated there and adopted by a number of other projects, I'm going to pin black to a specific version. We'll have to keep an eye on this as we go to make sure we're reasonably up to date.

@widdowquinn
Copy link
Owner

For future reference, the pre-commit autoupdate command will update the latest pinned version for each tool listed in the config file.

@baileythegreen
Copy link
Contributor Author

However you want to fix this is fine with me; I only meant to bring the issue to your attention and explain how I had resolved it.

Do you want me to test something on this end, to make sure it works in the environment that originally had the problem?

@widdowquinn
Copy link
Owner

I've pushed PR #271 which has you requested as a reviewer ;)

As it happens, changing the GitHub URL to point to psf doesn't fix the problem. The warning seems to appear only on first run to let the user know that the stable tag will not update black in future then - after that first time - uses the installed version and doesn't warn again.

The change of URL has no effect as there's an automatic redirection from https://github.com/ambv/black to https://github.com/psf/black

@baileythegreen
Copy link
Contributor Author

baileythegreen commented May 27, 2021

The warning seems to appear only on first run to let the user know that the stable tag will not update black in future then - after that first time - uses the installed version and doesn't warn again.

This is not entirely true. Perhaps it depends on something in the configuration, but I got the same error 10 different times—every time I tried submitting my commit—and it was actively preventing me from committing. I tried several things to fix it. The only thing that led to the error no longer being raised was changing ambv to psf in the pre-commit file.

@widdowquinn
Copy link
Owner

widdowquinn commented May 27, 2021

Changing the URL does not affect the warning, except to complain about the updated URL.

$ git status
On branch test_270
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   .pre-commit-config.yaml
[...]
$ head .pre-commit-config.yaml 
repos:
-   repo: https://github.com/ambv/black
    rev: stable
    hooks:
    - id: black
      language_version: python3
[...]
$ git add .pre-commit-config.yaml
$ git commit
[WARNING] The 'rev' field of repo 'https://github.com/ambv/black' appears to be a mutable reference (moving tag / branch).  Mutable references are never updated after first install and are not supported.  See https://pre-commit.com/#using-the-latest-version-for-a-repository for more details.  Hint: `pre-commit autoupdate` often fixes this.
[...]
$ head .pre-commit-config.yaml 
repos:
-   repo: https://github.com/psf/black
    rev: stable
    hooks:
    - id: black
      language_version: python3
[...]
$ git add .pre-commit-config.yaml 
$ git commit
[WARNING] The 'rev' field of repo 'https://github.com/psf/black' appears to be a mutable reference (moving tag / branch).  Mutable references are never updated after first install and are not supported.  See https://pre-commit.com/#using-the-latest-version-for-a-repository for more details.  Hint: `pre-commit autoupdate` often fixes this.

Pinning the black version removes the warning

$ head .pre-commit-config.yaml 
repos:
-   repo: https://github.com/psf/black
    rev: 21.5b1
    hooks:
    - id: black
      language_version: python3
[...]
$ git add .pre-commit-config.yaml
$ git commit
black................................................(no files to check)Skipped
blacken-docs.........................................(no files to check)Skipped

@baileythegreen
Copy link
Contributor Author

Well, it changes whether I get the warning in Atom, and whether I can commit from within the editor itself. I don't how, or if, that makes sense.

pyani automation moved this from To do to Done Jun 3, 2021
widdowquinn added a commit that referenced this issue Jun 3, 2021
Fixes Issue #270 by pinning `black` revision in `pre-commit` config. Also pins other application versions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something isn't working how it should
Projects
pyani
  
Done
Development

Successfully merging a pull request may close this issue.

2 participants