Migrating from black and flake8 to ruff

Posted by __Aaliyan__@reddit | Python | View on Reddit | 42 comments

as the title says, so i'm currently working on a relatively huge python/django codebase, built over the course of 6 years, which has been using black and flake8 for formatting and linting in pre-commit hook, both have their versions unupdated for about 3 years, now i have a somewhat difficult task on hand.

the formatting and linting engine is to be moved to ruff but in such a way that the formatting and linting changes reflected in codebase due to ruff are minimal, i can't seem to figure out a way of exporting either configs from black and flake8 in their current state so i can somehow replicate them in ruff to control the changes due to formatting. if anyone has been in a similar situation or know any potential way i can approach this, that woyld greatly help. cheers!

pre-commit-config.yaml (in its current state, as you can see versions are a bit older)

repos:
-   repo: https://github.com/psf/black
    rev: 19.10b0
    hooks:
    - id: black
      additional_dependencies: ['click==8.0.4']
-   repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v1.2.3
    hooks:
    - id: flake8
      args: [--max-line-length=120]
    - id: check-yaml