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

migrate style check to precommit #3111

Open
wants to merge 28 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 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
24 changes: 0 additions & 24 deletions .github/workflows/flake8.yml

This file was deleted.

11 changes: 11 additions & 0 deletions .github/workflows/lint_precommit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Lint checks by pre-commit

on: [push, pull_request]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: pre-commit/action@v3.0.1
22 changes: 9 additions & 13 deletions .github/workflows/style_type_checks.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
name: Style and type checks
name: License checks

on: [push, pull_request]

jobs:
style-type-checks:
license-checks:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: extractions/setup-just@v1
- uses: actions/setup-python@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Install dependencies
run: |
pip install .
# todo: install also `black[jupyter]`
pip install click "black==24.02" "mypy==1.8.0" \
types-python-dateutil types-waitress types-PyYAML
- name: Style check
run: just black
- name: Type check
run: just mypy
run: pip install click
- name: Check license headers
run: just license
59 changes: 59 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
default_language_version:
python: python3

ci:
autofix_prs: true
autoupdate_commit_msg: "[pre-commit.ci] pre-commit suggestions"
autoupdate_schedule: quarterly
# submodules: true

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
# - id: end-of-file-fixer
# - id: trailing-whitespace
# - id: check-json
# - id: check-yaml
# - id: check-toml
# - id: check-docstring-first
# - id: check-executables-have-shebangs
# - id: check-case-conflict
# - id: check-added-large-files
- id: detect-private-key

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.1.9"
hooks:
- id: ruff
name: Run Ruff (Flake8)
args: ["--fix", "--preview"]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
hooks:
- id: mypy
name: Run MyPy
args: ["--show-error-codes"]

- repo: https://github.com/PyCQA/docformatter
rev: v1.5.0
hooks:
- id: docformatter
name: Format docstrings with Docformatter
additional_dependencies: [tomli]
args: ["--in-place"]

- repo: https://github.com/psf/black
rev: 23.12.1
hooks:
- id: black
name: Format code with Black

#- repo: https://github.com/executablebooks/mdformat
# rev: 0.7.17
# hooks:
# - id: mdformat
# additional_dependencies:
# - mdformat-gfm
# - mdformat_frontmatter
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ exclude = ["src/gluonts/nursery"]


[tool.docformatter]
black = true
pre-summary-newline = true
make-summary-multi-line = true
wrap-descriptions = 79
Expand Down
Loading