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

[Feature]: Run ruff formatter on codebase #15

Open
rsnodgrass opened this issue May 28, 2024 · 1 comment
Open

[Feature]: Run ruff formatter on codebase #15

rsnodgrass opened this issue May 28, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@rsnodgrass
Copy link
Contributor

rsnodgrass commented May 28, 2024

Is your feature request related to a problem?

Code quality improvements.

Describe the solution you'd like

Run ruff formatter on all *.py files. Also should set the target Python version for the code repository in pyproject.toml (e.g. 3.10?) so when various code checking and formatting tools run they know what syntax is valid.

Describe alternatives you've considered

Ruff is starting to replace usage of the long-standing black8 and brunette formatters.

Additional context

Recommend adding .pre-commit-config.yaml in project root with the following once ruff has been run, so those that use pre-commit will ensure that new code automatically is formatted to the project's standards as well.

---
# pre-commit autoupdate

fail_fast: true

repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.6.0
    hooks:
      - id: trailing-whitespace
      - id: end-of-file-fixer

  # isort - sort import statements
  - repo: https://github.com/pycqa/isort
    rev: 5.13.2
    hooks:
      - id: isort
        files: \.(py)$
        args: [--settings-path=pyproject.toml]  # ["--profile", "black" ]

  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.4.4
    hooks:
      - id: ruff
        args: [ --fix ]  # run linter
      - id: ruff-format  # run formatter

  #### OPTIONAL: for keeping syntax more current

  - repo: https://github.com/asottile/pyupgrade
    rev: v3.15.2
    hooks:
      - id: pyupgrade
        args: [--py310-plus] # keep 2 versions behind current

  - repo: https://github.com/dosisod/refurb
    rev: v2.0.0
    hooks:
      - id: refurb
@rsnodgrass rsnodgrass added the enhancement New feature or request label May 28, 2024
@rsnodgrass
Copy link
Contributor Author

rsnodgrass commented May 28, 2024

See more at https://github.com/astral-sh/ruff

Could also add the GitHub workflow https://github.com/chartboost/ruff-action to send warnings on merges of new code that has not been formatted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant