mithril-security / blindai

Confidential AI deployment with secure enclaves :lock:
https://www.mithrilsecurity.io/
Apache License 2.0
502 stars 36 forks source link

add python and rust pre-commit lint/formatting #41

Closed CerineBnsd closed 2 years ago

CerineBnsd commented 2 years ago

Description

Use pre-commit hooks, to apply python lint/formatting and rust formatting automatically before making commits. Only once, when cloning the repo / pulling these changes, it's needed to install pre-commit:

pip install pre-commit

and run:

pre-commit install

Related Issue

None.

Type of change

Not affecting the existing codebase.

How Has This Been Tested?

On some test commits.

Checklist:

JoFrost commented 2 years ago

Cool stuff! Question though, why are you supporting Flake and Black in the same time? Those lints doesn't work too well together.

CerineBnsd commented 2 years ago

Cool stuff! Question though, why are you supporting Flake and Black in the same time? Those lints doesn't work too well together.

I thought like this as well, but I documented a bit and found things like this:

Does back replace flake8 ? Not at all. Black only reformats, you still run flake8 to check for various issues not covered by black. Flake8 very close to be perfectly compatible with black.

And actually that was right when I tested, black reformat the files, but doesn't check some issues that are only mentioned by flake8 (for example, using f strings with no placeholder ... ) that are useful, on the other hand, running flake alone won't reformat. The configuration that is used for flake eliminates the contradicting rules and worked fine.