python-3.xpre-commitflake8pre-commit.com

Pre-Commit throwing Errors on Missing whitespace after ":"


I used the same pre-commit configuration on my windows pc, but since i switched to a macos, whenever i run a pre-commit on my python-django project, i get unexpected errors like missing whitespace after colon, even when the said colon iS at the end of a class definition or function definition or colons present in a url string, i know from the docs that a space is not needed after this cases, i believe this has something to do with the os switch or some misconfiguration with pre-commit on my new pc,

Python VERSION: 3.12

pre-commit configuration

exclude: "^docs/|/migrations/"
default_stages: [commit]

repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.4.0
    hooks:
      - id: trailing-whitespace
      - id: end-of-file-fixer
      # - id: check-yaml

  - repo: https://github.com/asottile/pyupgrade
    rev: v3.3.1
    hooks:
      - id: pyupgrade
        args: [--py310-plus]

  - repo: https://github.com/psf/black
    rev: 22.12.0
    hooks:
      - id: black

  - repo: https://github.com/PyCQA/isort
    rev: 5.12.0
    hooks:
      - id: isort

  - repo: https://github.com/PyCQA/flake8
    rev: 6.0.0
    hooks:
      - id: flake8
        args: ["--config=setup.cfg"]
        additional_dependencies: [flake8-isort]

# sets up .pre-commit-ci.yaml to ensure pre-commit dependencies stay up to date
ci:
  autoupdate_schedule: weekly
  skip: []
  submodules: false

Sample Error Message

config/settings/production.py:109:21: E231 missing whitespace after ':'

Acutal line pointed at in the code

STATIC_URL = f"https://{aws_s3_domain}/{AWS_STORAGE_BUCKET_NAME}/payment/static/"

Can anyone help and is there a work around to this, i can disable this check in the pre-commit yaml file (which is counter-intuitive, cause i am using this checks to ensure my codebase is consistent), but again this was working fine on my windows pc, so i am trying to find an actual solution and not a hack.


Solution

  • you're using flake8 6.0 which does not support python 3.12 -- this support was added in flake8 6.1

    you either need to do one or the other of these:


    disclaimer: I maintain flake8 and I wrote pre-commit