Skip to content

Commit

Permalink
Use Ruff for Python linting and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
br3ndonland committed Jan 13, 2024
1 parent 94ea747 commit 43f6c18
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
3 changes: 1 addition & 2 deletions Brewfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ tap "homebrew/services"

brew "awscli"
brew "bash"
brew "black"
brew "ffmpeg"
brew "findutils"
brew "flake8"
brew "gh"
brew "git"
brew "git-lfs"
Expand Down Expand Up @@ -40,6 +38,7 @@ brew "prettier"
brew "python"
brew "r"
brew "rclone"
brew "ruff"
brew "rust"
brew "shellcheck"
brew "shfmt"
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,9 @@ I have tried GitHub's cloud-hosted VSCode, called [Codespaces](https://docs.gith

### Python

- I format Python code with [Black](https://black.readthedocs.io/en/stable/).
- The [Black VSCode extension](https://github.com/microsoft/vscode-black-formatter) provides support for Black. I set VSCode to autoformat on save.
- If you prefer the less-decisive PEP 8 format, I recommend [autopep8](https://pypi.org/project/autopep8/) for autoformatting.
- I format Python imports with [isort](https://pycqa.github.io/isort/).
- The [isort VSCode extension](https://github.com/microsoft/vscode-isort) provides support for isort.
- I lint and format Python code with [Ruff](https://docs.astral.sh/ruff/).
- The [Ruff VSCode extension](https://open-vsx.org/extension/charliermarsh/ruff) provides support for Ruff in VSCode. I set VSCode to autoformat on save.
- Ruff is available as a [Homebrew formula](https://formulae.brew.sh/formula/ruff).
- See my [template-python](https://github.com/br3ndonland/template-python) repo for useful tooling and additional sensible defaults.

## PGP
Expand Down
6 changes: 4 additions & 2 deletions vscode/User/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,10 @@
},
"[python]": {
"editor.codeActionsOnSave": {
"source.organizeImports": true
"source.fixAll": "always",
"source.organizeImports": "always"
},
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.rulers": [],
"editor.tabSize": 4
},
Expand Down Expand Up @@ -199,6 +200,7 @@
"python.showStartPage": false,
"python.testing.autoTestDiscoverOnSaveEnabled": false,
"python.testing.promptToConfigure": false,
"ruff.lint.args": ["--extend-select=I"],
"redhat.telemetry.enabled": false,
"shellcheck.enable": true,
"shellcheck.run": "onSave",
Expand Down
4 changes: 1 addition & 3 deletions vscode/extensions/marketplace-open-vsx.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
charliermarsh.ruff
codeium.codeium
dracula-theme.theme-dracula
eamodio.gitlens
Expand All @@ -8,9 +9,6 @@ golang.go
hashicorp.hcl
hashicorp.terraform
mikestead.dotenv
ms-python.black-formatter
ms-python.flake8
ms-python.isort
ms-python.mypy-type-checker
[email protected]
redhat.vscode-yaml
Expand Down

0 comments on commit 43f6c18

Please sign in to comment.