Skip to content

Commit

Permalink
style: Add Ruff and MyPy to pyproject.toml and integrate Python linti…
Browse files Browse the repository at this point in the history
…ng in GitHub Actions

       - Added Ruff and MyPy configurations to pyproject.toml
       - Integrated Python linting in GitHub Actions
  • Loading branch information
yanghao14 committed Jul 28, 2024
1 parent 3e71bb0 commit 9e7dbb5
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
20 changes: 19 additions & 1 deletion .github/workflows/compliance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,23 @@ jobs:
- uses: actions/checkout@v4
- name: Check license header
uses: apache/skywalking-eyes/[email protected]
- name: Check code style
- name: Check rust code style
run: cd python && make check-rust
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: pyproject.toml
- name: Check python code style
working-directory: ./python
- name: Install python linter dependencies
run: |
make setup-env
source venv/bin/activate
pip install ruff mypy
- name: Run python linter
working-directory: ./python
run: |
source venv/bin/activate
make check-python
7 changes: 7 additions & 0 deletions python/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ setup-venv: ## Setup the virtualenv
setup: ## Setup the requirements
$(info --- Setup dependencies ---)
pip install "$(MATURIN_VERSION)"
pip install ruff mypy

.PHONY: build
build: setup ## Build Python binding of delta-rs
Expand All @@ -48,6 +49,12 @@ check-rust: ## Run check on Rust
$(info --- Check Rust format ---)
cargo fmt --all -- --check

.PHONY: check-python
check-python: ## Run check on Python
$(info --- Check Python code quality ---)
ruff .
mypy .

.PHONY: test-rust
test-rust: ## Run tests on Rust
$(info --- Run Rust tests ---)
Expand Down
12 changes: 12 additions & 0 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,21 @@ dynamic = ["version"]
[tool.maturin]
module-name = "hudi._internal"

[tool.ruff]
line-length = 120
target-version = 'py38'
lint.mccabe = { max-complexity = 14 }
lint.extend-select = ['Q', 'RUF100', 'C90', 'UP', 'I']
lint.flake8-quotes = {inline-quotes = 'single', multiline-quotes = 'double'}
lint.pydocstyle = { convention = 'google' }
format.quote-style = 'single'

[tool.mypy]
files = "hudi/*.py"
exclude = "^tests"
warn_unused_configs = true
ignore_missing_imports = true
strict = true

[tool.pytest.ini_options]
testpaths = [
Expand Down

0 comments on commit 9e7dbb5

Please sign in to comment.