Skip to content

Commit

Permalink
Merge pull request #41 from Matatika/ruff-lint-format
Browse files Browse the repository at this point in the history
Setup Ruff linting/formatting
  • Loading branch information
ReubenFrankel authored Mar 6, 2024
2 parents 79158f0 + 6bed836 commit 302615a
Show file tree
Hide file tree
Showing 24 changed files with 277 additions and 544 deletions.
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

0 comments on commit 302615a

Please sign in to comment.