Pytest: Use an automatic code formatter and pre-commit hook?

Created on 11 May 2018  路  7Comments  路  Source: pytest-dev/pytest

Hi everyone,

I've been thinking about some time now to use an automatic code formatter to our codebase such as black or yapf, together with pre-commit and tox environments to check for compliance on CI.

Pros:

  • Consistent code formatting: currently the format is very mixed and we don't enforce it.
  • Help new contributors: no need to think or follow a style guide, it is done automatically.

Cons:

  • We will pollute the repository and lose some of the blame history.

Opinions?

infrastructure

Most helpful comment

@asottile appreciated - basically i want to copy what i did for setuptools_scm/sentaku and you did for tox&others ^^

All 7 comments

GitMate.io thinks possibly related issues are https://github.com/pytest-dev/pytest/issues/2390 (Use automatic CHANGELOG management), https://github.com/pytest-dev/pytest/issues/2832 (exit code 2 when using '-x' flag), https://github.com/pytest-dev/pytest/issues/2987 (Feature request: use caplog with custom formatter), https://github.com/pytest-dev/pytest/issues/2421 (ModuleNotFoundError when using the tests outside application code layout), and https://github.com/pytest-dev/pytest/issues/2124 (fixture hooks use session.ihook instead of a fitting hookproxy).

lets schedule this either right before or right after a major release
also lets take some extra care, since the tools are potentially problematic

i plan to test black on setuptools_scm again in future

Agree with doing it after a minor release (I take that's what you meant right?) and to take care in using the tools (we need to see how they behave on a day to day basis). I also plan to do it in some plugins myself before committing to do the same in pytest.

I wrote this mostly to start gathering opinions.

whops, yes thats what i meant

I'm willing to help with this if you'd like :)

@asottile appreciated - basically i want to copy what i did for setuptools_scm/sentaku and you did for tox&others ^^

I think we're good to call this done 馃憤

Was this page helpful?
0 / 5 - 0 ratings