This issue on the black issue tracker outlines your particular problem
pre-commit finds all the python files, then applies pre-commit‘s exclusion, and then passes that list of files to the underlying tools (in this case black)
black currently (at the time of writing) will format all files listed on the command line — independent of black‘s exclude pattern
the suggestion is to use pre-commit‘s exclusion (via your .pre-commit-config.yaml) such that those files are never passed to black at all:
- id: black
exclude: ^migrations/
note: unlike black, pre-commit will only ever lint files which are checked into your git repository, so the laundry list of exclusion is unnecessary here (.git / .mypy_cache / etc.)
disclaimer: I’m the author of pre-commit