Skip to content

Commit a02769d

Browse files
Bump ruff, drop autoflake, add darglint back (#1279)
* bump ruff version * remove autoflake * remove unused variable assignment * remove autoflake * ignore D401 errors * add noqa to avoid exceptions * add darglint back :( * fix missing docstrings * add darglint dependencies back * fix docstring indentation * Update .github/workflows/docstring.yml Co-authored-by: Alexej Penner <[email protected]> * fix linting errors --------- Co-authored-by: Alexej Penner <[email protected]>
1 parent b6871f3 commit a02769d

26 files changed

+252
-54
lines changed

.darglint

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[darglint]
2+
docstring_style=google

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,8 @@ jobs:
8585
markdown-link-check:
8686
uses: ./.github/workflows/markdown-link-check.yml
8787

88+
docstring-check:
89+
uses: ./.github/workflows/docstring.yml
90+
8891
spell-check:
8992
uses: ./.github/workflows/spellcheck.yml

.github/workflows/docstring.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Docstring Check
2+
3+
on: workflow_call
4+
5+
jobs:
6+
docstring:
7+
name: docstringcheck
8+
runs-on: ubuntu-latest
9+
env:
10+
ZENML_DEBUG: 1
11+
ZENML_ANALYTICS_OPT_IN: false
12+
PYTHONIOENCODING: "utf-8"
13+
14+
steps:
15+
- uses: actions/checkout@v2
16+
- name: Set up Python 3.7
17+
uses: actions/setup-python@v2
18+
with:
19+
python-version: "3.7"
20+
- name: Install Dependencies
21+
run: |
22+
python -m pip install --upgrade pip setuptools
23+
python -m pip install darglint
24+
- name: Docstring Check
25+
run: bash scripts/docstring.sh

docs/mkdocstrings_helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def generate_docs(
205205
)
206206

207207
integration_file_contents = [INTEGRATION_DOCS_TITLE]
208-
integrations_file_content = create_entity_docs(
208+
create_entity_docs(
209209
api_doc_file_dir=integrations_dev_doc_file_dir,
210210
ignored_modules=["__init__.py", "__pycache__"],
211211
sources_path=path / "integrations",

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,14 @@ server = ["fastapi", "uvicorn", "python-multipart", "python-jose", "fastapi-util
8686
black = "^22.3.0"
8787
pytest = "^6.2.4"
8888
mypy = "^0.991"
89-
ruff = "^0.0.223"
89+
ruff = "^0.0.238"
9090
coverage = { extras = ["toml"], version = "^5.5" }
9191
pre-commit = "^2.14.0"
92-
autoflake = "^1.4"
9392
pyment = "^0.3.3"
9493
tox = "^3.24.3"
9594
hypothesis = "^6.43.1"
9695
typing-extensions = ">=3.7.4"
96+
darglint = "^1.8.1"
9797

9898
# pytest dev dependencies
9999
pytest-randomly = "^3.10.1"
@@ -204,7 +204,7 @@ exclude = [
204204
]
205205
per-file-ignores = {}
206206
select = ["D", "E", "F", "I", "I001", "Q"]
207-
ignore = ["E501", "F401", "F403", "D301", "D403", "D407", "D213", "D203", "S101", "S104", "S105", "S106", "S107"]
207+
ignore = ["E501", "F401", "F403", "D301", "D401", "D403", "D407", "D213", "D203", "S101", "S104", "S105", "S106", "S107"]
208208
src = ["src", "test"]
209209
# use Python 3.7 as the minimum version for autofixing
210210
target-version = "py37"

scripts/docstring.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
set -x
4+
5+
DOCSTRING_SRC=${1:-"src/zenml tests/harness"}
6+
7+
export ZENML_DEBUG=1
8+
export ZENML_ANALYTICS_OPT_IN=false
9+
10+
darglint -v 2 $DOCSTRING_SRC

scripts/format.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ SRC=${1:-"src/zenml tests examples docs/mkdocstrings_helper.py"}
55

66
export ZENML_DEBUG=1
77
export ZENML_ANALYTICS_OPT_IN=false
8-
autoflake --remove-all-unused-imports --recursive --remove-unused-variables --in-place $SRC --exclude=__init__.py
8+
9+
# autoflake replacement: removes unused imports and variables
10+
ruff $SRC --select F401,F841 --fix --exclude "__init__.py" --isolated
11+
912
# sorts imports
1013
ruff $SRC --select I --fix --ignore D
1114
black $SRC

scripts/lint.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ ruff $SRC_NO_TESTS
1313
# TODO: Fix docstrings in tests and examples and remove the `--extend-ignore D` flag
1414
ruff $TESTS_EXAMPLES --extend-ignore D
1515

16-
# TODO: remove this once ruff implements the feature
17-
autoflake --remove-all-unused-imports --recursive --remove-unused-variables --in-place $SRC --exclude=__init__.py --check | ( grep -v "No issues detected" || true )
16+
# autoflake replacement: checks for unused imports and variables
17+
ruff $SRC --select F401,F841 --exclude "__init__.py" --isolated
1818

1919
black $SRC --check
2020

src/zenml/cli/artifact.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ def artifact() -> None:
3636
@cli_utils.list_options(ArtifactFilterModel)
3737
@artifact.command("list", help="List all artifacts.")
3838
def list_artifacts(**kwargs: Any) -> None:
39-
"""List all artifacts."""
39+
"""List all artifacts.
40+
41+
Args:
42+
**kwargs: Keyword arguments to filter artifacts.
43+
"""
4044
cli_utils.print_active_config()
4145
artifacts = Client().list_artifacts(**kwargs)
4246

src/zenml/cli/pipeline.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ def cli_pipeline_run(python_file: str, config_path: str) -> None:
5858
@pipeline.command("list", help="List all registered pipelines.")
5959
@list_options(PipelineFilterModel)
6060
def list_pipelines(**kwargs: Any) -> None:
61-
"""List all registered pipelines."""
61+
"""List all registered pipelines.
62+
63+
Args:
64+
**kwargs: Keyword arguments to filter pipelines.
65+
"""
6266
cli_utils.print_active_config()
6367
client = Client()
6468
with console.status("Listing pipelines...\n"):
@@ -180,7 +184,11 @@ def runs() -> None:
180184
@runs.command("list", help="List all registered pipeline runs.")
181185
@list_options(PipelineRunFilterModel)
182186
def list_pipeline_runs(**kwargs: Any) -> None:
183-
"""List all registered pipeline runs for the filter."""
187+
"""List all registered pipeline runs for the filter.
188+
189+
Args:
190+
**kwargs: Keyword arguments to filter pipeline runs.
191+
"""
184192
cli_utils.print_active_config()
185193

186194
client = Client()

0 commit comments

Comments
 (0)