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

multiple mutable rev warnings issued on autoupdate #2010

Closed
graingert opened this issue Aug 14, 2021 · 2 comments · Fixed by #2030
Closed

multiple mutable rev warnings issued on autoupdate #2010

graingert opened this issue Aug 14, 2021 · 2 comments · Fixed by #2030

Comments

@graingert
Copy link

graingert commented Aug 14, 2021

when running pre-commit autoupdate I get 2 warnings per mutable rev, when I expected 0 see #974

~/projects/pytest-cov   pre-commit-autoupdate  pipx run pre-commit autoupdate    
[WARNING] The 'rev' field of repo 'https://github.com/pre-commit/pre-commit-hooks' 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.
[WARNING] The 'rev' field of repo 'https://github.com/timothycrosley/isort' 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.
[WARNING] The 'rev' field of repo 'https://gitlab.com/pycqa/flake8' 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.
[WARNING] The 'rev' field of repo 'https://github.com/pre-commit/pre-commit-hooks' 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.
[WARNING] The 'rev' field of repo 'https://github.com/timothycrosley/isort' 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.
[WARNING] The 'rev' field of repo 'https://gitlab.com/pycqa/flake8' 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.
Updating https://github.com/pre-commit/pre-commit-hooks ... updating master -> v4.0.1.
Updating https://github.com/timothycrosley/isort ... updating master -> 5.9.3.
Updating https://gitlab.com/pycqa/flake8 ... updating master -> 3.9.2.
@paulhfischer
Copy link
Contributor

paulhfischer commented Aug 14, 2021

this affects all config validation checks (e.g. also unknown keywords), as the config is validated twice (migration and updating).

This might be fixable by suppressing the logger.warning output if the migration is being called with silent=True, as it is done whilst autoupdating. If this sounds like a reasonable approach to you @asottile, I can change/add this if you want.

(this context should do the trick)

import logging

from contextlib import contextmanager
from typing import Generator

@contextmanager
def suppress_warnings(logger: logging.Logger) -> Generator[None, None, None]:
    old_level = logger.getEffectiveLevel()
    logger.setLevel(logging.ERROR)

    try:
        yield
    finally:
        logger.setLevel(old_level)

@asottile
Copy link
Member

since this is cosmetic and harmless I don't want to do any invasive "fixes" for this, but I suspect this line can be removed (as it will need to be removed anyway when list-based configurations are finally removed in 3.x):

# ensure that the configuration is a valid pre-commit configuration
load_config(config_file)

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

Successfully merging a pull request may close this issue.

3 participants