Skip to content

Pre commit#2

Open
J4bbi wants to merge 2 commits intodevelopfrom
feature/pre-commit
Open

Pre commit#2
J4bbi wants to merge 2 commits intodevelopfrom
feature/pre-commit

Conversation

@J4bbi
Copy link
Copy Markdown
Collaborator

@J4bbi J4bbi commented Mar 11, 2025

This PR introduces configuration to use the following pre commit hooks:

It is easy to have differing opinions about code style but it is desirable to agree on some baseline. Having a character limit makes code more readable. Inconsistent style can be unnecessarily distracting.

The enforcement in this PR makes several concessions.

  • character line limit is 120 characters as opposed to the PEP8 limit of 79 characters.
  • flake8 will ignore the following error codes D102, D202, D205, D209, D400, D401, D107 (see a list of D class error codes from pydocstyle here)

Use

Pycharm can be configure to run pre-commit before committing (it seemed to pick up this configuration automatically).

Make sure you have the latest version of pre-commit installed (version 4.1.0).

To run the check:

pre-commit run --all-files

Black will make style changes automatically. You can add --in-place as an argument for the doc-formatter in the pre-commit config file to allow it to make changes. The default behaviour is to show suggested diffs for changes. Use this with caution however as it does not understand large docstrings with code examples well and is prone to squash them together into something unintelligible.

If everything's okay we get this nice output:

image

@J4bbi J4bbi requested a review from richard-jones March 11, 2025 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant