Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

DOC: Style guide could indicate formatters / pre-commit hook #21424

Copy link
Copy link
Open
@tgross35

Description

@tgross35
Issue body actions

Issue with current documentation:

I'm working through my first issue with the project, and struggling to find information on whether there is a recommended formatter. The source currently seems to use a mix of optional styles (single vs. double quotes, backslash vs. brackets, formatting of non-python files, etc.) and I think that some more specific in the docs, possibly with recommended formatters and/or formatter config files, would help to simplify things a bit.

The only reference to style that I found was here: https://numpydoc.readthedocs.io/en/latest/format.html

Idea or request for content:

Plenty of projects use Black to format code, and I don't think that would be a bad idea here. If there are some custom style options that Numpy prefers to stick with, then something like Autopep8 or YAPF would probably be configurable to work.

A simpler option would be to add a precommit hook that handles formatting, just to be able to easier enforce consistency. Even if the hook isn't enforced in the pipeline, it would at least help give devs some direction when working locally. At a minimum, the following hooks would be quite useful:

  • Black (with line length 79 to match pycodestyle)
  • flake8, recommended in the Numpy style guide
  • trailing-whitespace
  • end-of-file-fixer
  • clang-format, to implement the config from here ENH: Add clang-format file #19754

Optionally, some other nice to have hooks would be:

  • isort
  • pretty-format-ini
  • pretty-format-toml
  • pretty-format-yaml
  • check-toml
  • check-yaml
  • fix-byte-order-marker
  • mixed-line-ending

If there is interest in this, I would be happy to submit a PR. Of course, it is possible that this has been discussed before and there's a reason it doesn't exist. I couldn't find anything in the issues list, but I figure there must be a reason why linter.py is used instead of a precommit hook.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.