Skip to content
Open
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
61 changes: 61 additions & 0 deletions .github/workflows/lint_fix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Lint Fix

on:
pull_request:
branches:
- main

concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.ref }}

jobs:
lint-fix:
name: Fix linting issues
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write

steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Update pip to the latest version
run: |
python -m pip install --upgrade pip

- name: Set up Python tools
run: |
make dev

- name: Run format
run: |
make format

# Commit and push changes if any
- name: Check for changes
id: git-check
run: |
git diff --exit-code || echo "changes=true" >> $GITHUB_OUTPUT
git diff --cached --exit-code || echo "changes=true" >> $GITHUB_OUTPUT

- name: Commit and push if there are changes
if: steps.git-check.outputs.changes == 'true'
run: |
git config --local user.email "[email protected]"
git config --local user.name "github-actions[bot]"
git add -A
git commit -m "🤖 Auto-fix linting issues" || exit 0
git push

7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: clean deepclean prerequisite dependencies lightgbm rl develop lint docs package test analysis all install dev black pylint flake8 mypy nbqa nbconvert lint build upload docs-gen
.PHONY: clean deepclean prerequisite dependencies lightgbm rl develop lint docs package test analysis all install dev black format pylint flake8 mypy nbqa nbconvert lint build upload docs-gen
#You can modify it according to your terminal
SHELL := /bin/bash

Expand Down Expand Up @@ -118,6 +118,11 @@ dev: prerequisite all
black:
black . -l 120 --check --diff --exclude qlib/_version.py

# Format code with black (auto-fix).
format:
black . -l 120 --exclude qlib/_version.py
nbqa black . -l 120

# Check code folder with pylint.
# TODO: These problems we will solve in the future. Important among them are: W0221, W0223, W0237, E1102
# C0103: invalid-name
Expand Down
Loading