Skip to content

Commit ed97bb3

Browse files
committed
Add pyproject, move to ruff, delete manifest.in
1 parent a88ea27 commit ed97bb3

File tree

6 files changed

+126
-36
lines changed

6 files changed

+126
-36
lines changed

.github/workflows/python-lint.yml

+33-15
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,39 @@ jobs:
1111
runs-on: ubuntu-latest
1212

1313
steps:
14-
- uses: actions/checkout@v3
15-
- uses: actions/setup-python@v4
16-
with:
17-
python-version: '3.8'
18-
- name: install deps
19-
run: pip install flake8==3.9.0 black==22.3.0 pre-commit-hooks==2.4.0
20-
21-
- name: black
22-
run: black --check python
14+
- uses: actions/checkout@v4
2315

24-
- name: flake8
25-
run: flake8 --config python/.flake8 python
16+
- uses: actions/setup-python@v5
17+
with:
18+
python-version: "3.11"
2619

27-
- name: trailing-whitespace-fixer
28-
run: trailing-whitespace-fixer $(find python -name "*.py" -type f) || exit 1
20+
- name: Get all changed files
21+
id: get-changed-files
22+
uses: tj-actions/changed-files@v44
23+
with:
24+
files_yaml: |
25+
src:
26+
- 'python/**/*.py'
27+
- '!python/tests/**/*.py'
28+
test:
29+
- 'python/tests/**/*.py'
2930
30-
- name: end-of-file-fixer
31-
run: end-of-file-fixer $(find python -name "*.py" -type f) || exit 1
31+
- name: install deps
32+
run: pip install ruff==0.4.2
33+
34+
- name: ruff on python files
35+
if: steps.get-changed-files.outputs.src_any_changed == 'true'
36+
env:
37+
SRC_ALL_CHANGED_FILES: ${{ steps.get-changed-files.outputs.src_all_changed_files }}
38+
run: ruff check --output-format=github $SRC_ALL_CHANGED_FILES
39+
40+
- name: ruff on test files
41+
if: steps.get-changed-files.outputs.test_any_changed == 'true'
42+
env:
43+
TEST_ALL_CHANGED_FILES: ${{ steps.get-changed-files.outputs.test_all_changed_files }}
44+
run: ruff check --output-format=github $TEST_ALL_CHANGED_FILES
45+
46+
- name: ruff format --check $ALL_CHANGED_FILES
47+
env:
48+
ALL_CHANGED_FILES: ${{ steps.get-changed-files.outputs.all_changed_files }}
49+
run: ruff format $ALL_CHANGED_FILES

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ coverage.xml
5050
*.cover
5151
.hypothesis/
5252
.pytest_cache/
53+
.ruff_cache/
5354

5455
# Translations
5556
*.mo

python/.flake8

-4
This file was deleted.

python/.pre-commit-config.yaml

+5-15
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,8 @@
11
exclude: setup.py
22
repos:
3-
- repo: https://github.com/psf/black
4-
rev: 22.3.0
3+
- repo: https://github.com/astral-sh/ruff-pre-commit
4+
rev: v0.4.2
55
hooks:
6-
- id: black
7-
language_version: python3
8-
- repo: https://gitlab.com/pycqa/flake8
9-
rev: 3.8.3
10-
hooks:
11-
- id: flake8
12-
language_version: python3
13-
args: [--config=python/.flake8]
14-
- repo: https://github.com/pre-commit/pre-commit-hooks
15-
rev: v2.4.0
16-
hooks:
17-
- id: trailing-whitespace
18-
- id: end-of-file-fixer
6+
- id: ruff
7+
args: [--fix]
8+
- id: ruff-format

python/MANIFEST.in

-2
This file was deleted.

python/pyproject.toml

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
[build-system]
2+
requires = ["setuptools", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[tool.setuptools.packages.find]
6+
exclude = ["tests*"]
7+
include = ["../Readme.md", "../LICENSE"]
8+
9+
[tool.setuptools.dynamic]
10+
version = { attr = "hsfs.version.__version__" }
11+
12+
[tool.ruff]
13+
# Exclude a variety of commonly ignored directories.
14+
exclude = [
15+
".bzr",
16+
".direnv",
17+
".eggs",
18+
".git",
19+
".git-rewrite",
20+
".hg",
21+
".ipynb_checkpoints",
22+
".mypy_cache",
23+
".nox",
24+
".pants.d",
25+
".pyenv",
26+
".pytest_cache",
27+
".pytype",
28+
".ruff_cache",
29+
".svn",
30+
".tox",
31+
".venv",
32+
".vscode",
33+
"__pypackages__",
34+
"_build",
35+
"buck-out",
36+
"build",
37+
"dist",
38+
"node_modules",
39+
"site-packages",
40+
"venv",
41+
"java",
42+
]
43+
44+
# Same as Black.
45+
line-length = 88
46+
indent-width = 4
47+
48+
# Assume Python 3.8+ syntax.
49+
target-version = "py38"
50+
51+
[tool.ruff.lint]
52+
# 1. Enable flake8-bugbear (`B`) rules, in addition to the defaults.
53+
select = ["E4", "E7", "E9", "F", "B", "I", "W"] #, "ANN"]
54+
ignore = [
55+
"B905", # zip has no strict kwarg until Python 3.10
56+
"ANN101", # Missing type annotation for self in method
57+
"ANN102", # Missing type annotation for cls in classmethod
58+
"ANN003", # Missing type annotation for **kwarg in function
59+
"ANN002", # Missing type annotation for *args in function
60+
"ANN401", # Allow Any in type annotations
61+
"W505", # Doc line too long
62+
]
63+
64+
# Allow fix for all enabled rules (when `--fix`) is provided.
65+
fixable = ["ALL"]
66+
unfixable = []
67+
68+
# Allow unused variables when underscore-prefixed.
69+
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
70+
71+
[tool.ruff.lint.isort]
72+
lines-after-imports = 2
73+
known-third-party = ["hopsworks", "hsfs", "hsml"]
74+
75+
76+
[tool.ruff.format]
77+
# Like Black, use double quotes for strings.
78+
quote-style = "double"
79+
80+
# Like Black, indent with spaces, rather than tabs.
81+
indent-style = "space"
82+
83+
# Like Black, respect magic trailing commas.
84+
skip-magic-trailing-comma = false
85+
86+
# Like Black, automatically detect the appropriate line ending.
87+
line-ending = "auto"

0 commit comments

Comments
 (0)