dandi / dandi-schema

Schemata for DANDI archive project
Apache License 2.0
7 stars 10 forks source link

Setup pre-commit black'ing and linting similarly to dandi-cli #35

Closed yarikoptic closed 3 years ago

jwodder commented 3 years ago

@yarikoptic It is set up; the configuration is copied directly from dandi-cli. In what way is it not working appropriately?

yarikoptic commented 3 years ago

@yarikoptic It is set up; the configuration is copied directly from dandi-cli.

d'oh -- my bad, indeed it is there and I see the pre-commit hooks in .git/hooks.

In what way is it not working appropriately?

for #34 I managed to do locally commit and then push to only get linters unhappy with fixes to follow in https://github.com/dandi/dandischema/pull/34/commits/f129f151cb229fd496eb3cee6ba8022d7e397ed4 (unused imports, comments format), and https://github.com/dandi/dandischema/pull/34/commits/a27108402e0b3a78d4ff1b9aed0a99af9173432b (too long lines).

May be there is a quick way to just run tox -e lint as part of the precommit to at least ensure (but IIRC for dandi-cli I have black splitting long lines etc) that I am not committing with a lint?

satra commented 3 years ago

just an fyi. this is the pre-commit file i'm using in nobrainer and this will take care of a lot of the issues. https://github.com/neuronets/nobrainer/blob/master/.pre-commit-config.yaml (that repo also has the precommit-ci setup).

jwodder commented 3 years ago

@yarikoptic Black just does formatting; it doesn't care about unused imports. It also, for some reason, doesn't edit comments beginning with multiple #'s despite those sometimes being rejected by flake8. As for long lines, if they're long because they contain a long string, black won't break the string up (but I think that might be on black's to-do list).

One wouldn't run tox itself through pre-commit; one would instead directly run the lint commands that tox runs.

yarikoptic commented 3 years ago

ok, could we run the lint command we use for tox?