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

Hook specifies language_version but is using language system problem when upgrading to 2.10.0 #1790

Closed
tbjers opened this issue Feb 6, 2021 · 4 comments
Labels

Comments

@tbjers
Copy link

tbjers commented Feb 6, 2021

After upgrading to 2.10.0 I am now facing a hard fail for hooks that are using system.

For instance:

The hook `black` specifies `language_version` but is using language `system` which does not install an environment.

This used to work fine in 2.9.3 which was my previous version.

My particular setup uses Pipenv, Django, Black, and Pylint.

Now my options are to use either python or python_venv, none of which actually work for me.

I tried to use additional_dependencies, which still doesn't work because pylint_django requires a configured Django project in order to load the configuration file and similar.

Is there a new way of doing this that I am not aware of? I've looked at the docs and can't figure this one out.

Please advise.

Pipfile:

[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
babel = "*"
bottlenose = "*"
django = "*"
django-anymail = { extras = ["mailgun"], version = "*" }
django-compressor = "*"
django-dynamic-preferences = "*"
django-environ = "*"
django-perms-provisioner = "*"
django-sass-processor = "*"
flask-cors = "*"
gunicorn = "*"
libsass = "*"
measurement = "*"
polib = "*"
psycopg2-binary = "*"
python-dateutil = "*"
pyyaml = "*"
sqlalchemy = "*"
timezones = "*"
whitenoise = { extras = ["brotli"], version = "*" }
rollbar = "*"

[dev-packages]
black = "~=20.8b1"
coverage = { extras = ["toml"], version = "*" }
install = "*"
invoke = "*"
pre-commit = "*"
pylint = "~=2.6"
pylint-django = "*"
skjold = "*"
wheel = "*"
faker = "*"

[requires]
python_version = "3.7"

[pipenv]
allow_prereleases = true

.pre-commit-config.yaml:

default_language_version:
  python: python3.7
repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v3.2.0
    hooks:
      - id: trailing-whitespace
      - id: check-executables-have-shebangs
      - id: debug-statements
      - id: check-merge-conflict
      - id: name-tests-test
        args: ["--django"]

  - repo: https://github.com/psf/black
    rev: 20.8b1
    hooks:
      - id: black
        language: system
        args: ["--line-length=120"]

  - repo: https://github.com/pre-commit/mirrors-pylint
    rev: v2.3.1
    hooks:
      - id: pylint
        language: system
        args: ["--rcfile=pylintrc", "--load-plugins=pylint_django"]

  - repo: https://github.com/twu/skjold
    rev: v0.2.0
    hooks:
      - id: skjold

pyproject.toml:

[tool.black]
line-length = 120
target-version = ['py36', 'py37', 'py38']
include = '\.pyi?$'
exclude = '''
/(
    \.git
  | \.venv
  | build
  | dist
)/
'''

[tool.skjold]
report_only = true
report_format = "json"
sources = ["pyup", "github", "gemnasium"]
cache_dir = ".skjold_cache"
cache_expires = 43200

[tool.pytest.ini_options]
minversion = "6.0"
addopts = "-s"
log_cli_level = "INFO"
testpaths = ["tests"]
filterwarnings = [
    "ignore::DeprecationWarning",
    "ignore::PendingDeprecationWarning",
    "ignore::UserWarning",
]
@asottile
Copy link
Member

asottile commented Feb 6, 2021

If you're using language: system then you're not installing a particular language -- there's no reason to use repo: ... for that, you probably want to use repo: local

in your case, you're inheriting language_version from the base repository

this is an intentional change because your configuration is misconfigured and was leading to confusion

@tbjers
Copy link
Author

tbjers commented Feb 6, 2021

@asottile I am using the hook repositories because they provide the functionality out of the box so that I don't have to manually write the file matching and any other arguments into the pre-commit configuration file.

this is an intentional change because your configuration is misconfigured and was leading to confusion

How are we supposed to set up Python projects with Django and pylint to work properly with pre-commit in the future?

@asottile
Copy link
Member

asottile commented Feb 6, 2021

@asottile I am using the hook repositories because they provide the functionality out of the box so that I don't have to manually write the file matching and any other arguments into the pre-commit configuration file.

this is an intentional change because your configuration is misconfigured and was leading to confusion

How are we supposed to set up Python projects with Django and pylint to work properly with pre-commit in the future?

Use a repository local hook, as shown in the documentation (there's an example for pylint there). I would not suggest using language: system for black

@tbjers
Copy link
Author

tbjers commented Feb 6, 2021

@asottile awesome, thank you for this. My configuration now works great with pre-commit again!

enpaul added a commit to enpaul/tox-poetry-installer that referenced this issue Feb 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants