Ensuring formatting does not produce a diff before merge request using a pipeline

Hi,

I have what I think is a very simple problem. I would like to set up my merge requests with a pipeline/check (Merge request pipelines | GitLab) such that they will not pass if the code is not formatted/linted properly. In this case it is Python code and I want to check it against the black formatter to ensure formatting does not produce a diff.

I can’t seem to find any documentation that shows the very basics of setting this up/what I need to do. Ideally I’d like it to apply to a group, and disable for specific projects if needed.

If someone can point me in the right direction I’d appreciate it.

Thanks,
Juliette L.