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

Setup Ruff linting/formatting #41

Merged
merged 4 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 38 additions & 16 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,39 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
ci:
autofix_prs: true
autoupdate_schedule: weekly
autoupdate_commit_msg: 'chore: pre-commit autoupdate'

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: local
hooks:
- id: lint
name: Lint
language: system
entry: make lint
pass_filenames: false
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-json
exclude: |
(?x)^(
\.vscode/.*\.json
)$
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.27.3
hooks:
- id: check-dependabot
- id: check-github-workflows

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.14
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix, --show-fixes]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
hooks:
- id: mypy
additional_dependencies:
- types-requests
exclude: tests/
19 changes: 5 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
.PHONY: help init lint lint-fix test
.PHONY: help init lint test

help:
@echo AVAILABLE COMMANDS
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-23s\033[0m%s\n", $$1, $$2}'

init: ## Initialise repo for local development
@poetry install -v
@! test -d ~/.cache/pre-commit || poetry run pre-commit clean
@poetry run pre-commit install -f --install-hooks
@poetry install --sync --with dev
@poetry run pre-commit install --install-hooks

lint: ## Lint source files
poetry run autoflake --check --recursive --exclude tests --remove-all-unused-imports --remove-duplicate-keys --remove-unused-variables --verbose tap_spotify
poetry run isort --check --diff tap_spotify
poetry run black --check --diff tap_spotify
poetry run flake8 --max-complexity 10 tap_spotify

lint-fix: ## Lint source files and fix any issues
poetry run autoflake --in-place --recursive --exclude tests --remove-all-unused-imports --remove-duplicate-keys --remove-unused-variables --verbose tap_spotify
poetry run isort tap_spotify
poetry run black tap_spotify
lint: ## Lint files
poetry run pre-commit run ruff

test: ## Run tests
@poetry run pytest
Loading