Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pre-commit] pre-commit configuration: blank lines and trailing spaces #863

Merged
merged 4 commits into from
Apr 1, 2023

Conversation

jhillairet
Copy link
Member

Add a minimal configuration file to use with pre-commit. (Will lead to many small trailing spaces and etc in a foreseen distinct PR)

To be discussed, if we should use additional hooks:

but excludes meta.yaml, which fails on the '{%' at first line
@FranzForstmayr
Copy link
Collaborator

FranzForstmayr commented Mar 27, 2023

+1 for using a code formatter, I'm also using black most of the time.
Instead of isort I would recommend to use ruff, which is a de facto successor of flake8.
ruff has lots of plugins builtin (including isort) and is really fast.

https://github.com/charliermarsh/ruff

@eendebakpt
Copy link
Contributor

+1 for a code formatter. black is nice (with perhaps max-line length increased a bit), although autopep8 is also good
+1 for ruff. Instead of having multiple tools (isort, flake, etc.) one just needs a single tool.

Here is the configuration file I use

exclude: 'doc/conf.py'

repos:

-   repo: https://github.com/psf/black
    rev: 23.1.0
    hooks:
      - id: black

- repo: https://github.com/nbQA-dev/nbQA
  rev: 1.6.3
  hooks:
    - id: nbqa-black
      additional_dependencies: [black==23.1]
    - id: nbqa-ruff
      args: [--fix, --exit-non-zero-on-fix]

- repo: https://github.com/charliermarsh/ruff-pre-commit
  # Ruff version.
  rev: 'v0.0.253'
  hooks:
    - id: ruff
      args: [--fix, --exit-non-zero-on-fix]

with in pyproject.toml:

... 

[tool.ruff]
select = ["E", "F", "UP", "I"]
ignore = [ #"UP031", # use format specifiers instead of percent format
            #"F401", # imported but unused
        ]
line-length = 120

target-version = "py38"

To reduce the amount of changes in the codebase, one could remove the "UP" or add more rules to the ignore

@cafeclimber
Copy link
Contributor

Another +1 for Black and Ruff!

@jhillairet jhillairet changed the title Add pre-commit configuration [pre-commit] pre-commit configuration Mar 29, 2023
@jhillairet jhillairet merged commit 6b371d1 into scikit-rf:master Apr 1, 2023
@jhillairet jhillairet changed the title [pre-commit] pre-commit configuration [pre-commit] pre-commit configuration: blank lines and trailing spaces Apr 2, 2023
@jhillairet
Copy link
Member Author

Hum, I did not intend to merge it. Seems it autocally merged it when I merged #863 (which was branched from from)..

I'll do another PR to add ruff and black

@jhillairet jhillairet mentioned this pull request Apr 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community Improvements Improvements of existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants