From 365e6ec1c9bdf9e740647c07ac224890d4058c60 Mon Sep 17 00:00:00 2001 From: Mattt Zmuda Date: Sun, 29 Oct 2023 03:57:04 -0700 Subject: [PATCH 1/7] Pin ruff to >= 0.1.3 Signed-off-by: Mattt Zmuda --- pyproject.toml | 2 +- requirements-dev.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 0ca22dec..570bbac8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,7 @@ optional-dependencies = { dev = [ "pytest-asyncio", "pytest-recording", "respx", - "ruff", + "ruff>=0.1.3", ] } [project.urls] diff --git a/requirements-dev.txt b/requirements-dev.txt index 5906f987..aeffe8b1 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -67,7 +67,7 @@ pyyaml==6.0.1 # via vcrpy respx==0.20.2 # via replicate (pyproject.toml) -ruff==0.0.278 +ruff==0.1.3 # via replicate (pyproject.toml) sniffio==1.3.0 # via From 6b4523577312ece0d8c93dd3be5e1a446202b9f5 Mon Sep 17 00:00:00 2001 From: Mattt Zmuda Date: Sun, 29 Oct 2023 03:53:58 -0700 Subject: [PATCH 2/7] Ignore W191 linting rule Signed-off-by: Mattt Zmuda --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 570bbac8..d4fa6d1c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -56,6 +56,7 @@ ignore = [ "ANN003", # Missing type annotation for `**kwargs` "ANN101", # Missing type annotation for self in method "ANN102", # Missing type annotation for cls in classmethod + "W191", # Indentation contains tabs ] [tool.ruff.per-file-ignores] From 7756e868a607eacaa5a3599ee4d5cd8c6367606a Mon Sep 17 00:00:00 2001 From: Mattt Zmuda Date: Sun, 29 Oct 2023 03:52:05 -0700 Subject: [PATCH 3/7] Update VSCode settings to use ruff as default formatter Signed-off-by: Mattt Zmuda --- .vscode/extensions.json | 1 - .vscode/settings.json | 9 ++++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 5e1d573a..6c37dd45 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,7 +1,6 @@ { "recommendations": [ "charliermarsh.ruff", - "ms-python.black-formatter", "ms-python.python", "ms-python.vscode-pylance", "ms-python.mypy-type-checker" diff --git a/.vscode/settings.json b/.vscode/settings.json index 6752166d..6c0888dd 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -7,12 +7,12 @@ "files.insertFinalNewline": true, "files.trimFinalNewlines": true, "[python]": { - "editor.defaultFormatter": "ms-python.black-formatter", + "editor.defaultFormatter": "charliermarsh.ruff", "editor.formatOnSave": true, "editor.codeActionsOnSave": { "source.fixAll": true, "source.organizeImports": true - }, + } }, "python.languageServer": "Pylance", "python.testing.pytestArgs": [ @@ -25,7 +25,10 @@ "--show-column-numbers", "--no-pretty" ], - "ruff.args": [ + "ruff.lint.args": [ + "--config=pyproject.toml" + ], + "ruff.format.args": [ "--config=pyproject.toml" ], } From 866d26e2aa1efe9baa0978a280521ff60033c175 Mon Sep 17 00:00:00 2001 From: Mattt Zmuda Date: Sun, 29 Oct 2023 03:54:25 -0700 Subject: [PATCH 4/7] Run ruff format on project Signed-off-by: Mattt Zmuda --- replicate/json.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/replicate/json.py b/replicate/json.py index 8884cd06..4223ad48 100644 --- a/replicate/json.py +++ b/replicate/json.py @@ -12,7 +12,8 @@ def encode_json( - obj: Any, upload_file: Callable[[io.IOBase], str] # noqa: ANN401 + obj: Any, + upload_file: Callable[[io.IOBase], str], # noqa: ANN401 ) -> Any: # noqa: ANN401 """ Return a JSON-compatible version of the object. From e2814c66fd631699f94ba77cf29e8ff6b3dee94a Mon Sep 17 00:00:00 2001 From: Mattt Zmuda Date: Sun, 29 Oct 2023 03:59:34 -0700 Subject: [PATCH 5/7] Replace black with ruff format check in CI workflow Signed-off-by: Mattt Zmuda --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index af98f4a8..f463934d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -37,6 +37,6 @@ jobs: run: | python -m mypy replicate python -m ruff . - python -m black --check . + python -m ruff format --check . - name: Test run: python -m pytest From 72d05a54b30c374c7596c8ae87b068dfc5039a1f Mon Sep 17 00:00:00 2001 From: Mattt Zmuda Date: Sun, 29 Oct 2023 04:00:07 -0700 Subject: [PATCH 6/7] Remove black from dev dependencies Signed-off-by: Mattt Zmuda --- pyproject.toml | 1 - requirements-dev.txt | 13 +------------ 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d4fa6d1c..d06eb352 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,6 @@ authors = [{ name = "Replicate, Inc." }] requires-python = ">=3.8" dependencies = ["packaging", "pydantic>1", "httpx>=0.21.0,<1"] optional-dependencies = { dev = [ - "black", "mypy", "pytest", "pytest-asyncio", diff --git a/requirements-dev.txt b/requirements-dev.txt index aeffe8b1..8a4a1539 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -8,14 +8,10 @@ annotated-types==0.5.0 # via pydantic anyio==3.7.1 # via httpcore -black==23.7.0 - # via replicate (pyproject.toml) certifi==2023.7.22 # via # httpcore # httpx -click==8.1.6 - # via black h11==0.14.0 # via httpcore httpcore==0.17.3 @@ -36,18 +32,11 @@ multidict==6.0.4 mypy==1.4.1 # via replicate (pyproject.toml) mypy-extensions==1.0.0 - # via - # black - # mypy + # via mypy packaging==23.1 # via - # black # pytest # replicate (pyproject.toml) -pathspec==0.11.1 - # via black -platformdirs==3.9.1 - # via black pluggy==1.2.0 # via pytest pydantic==2.0.3 From 9a2ac795fd4967136a5a2d1b8cdf9435d60d3a89 Mon Sep 17 00:00:00 2001 From: Mattt Zmuda Date: Sun, 29 Oct 2023 04:12:11 -0700 Subject: [PATCH 7/7] Ignore ANN401 for dynamically typed expressions Signed-off-by: Mattt Zmuda --- replicate/client.py | 2 +- replicate/json.py | 4 ++-- replicate/version.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/replicate/client.py b/replicate/client.py index 19753c2b..cef9f46a 100644 --- a/replicate/client.py +++ b/replicate/client.py @@ -98,7 +98,7 @@ def trainings(self) -> TrainingCollection: def deployments(self) -> DeploymentCollection: return DeploymentCollection(client=self) - def run(self, model_version: str, **kwargs) -> Union[Any, Iterator[Any]]: + def run(self, model_version: str, **kwargs) -> Union[Any, Iterator[Any]]: # noqa: ANN401 """ Run a model and wait for its output. diff --git a/replicate/json.py b/replicate/json.py index 4223ad48..5964b7fc 100644 --- a/replicate/json.py +++ b/replicate/json.py @@ -12,8 +12,8 @@ def encode_json( - obj: Any, - upload_file: Callable[[io.IOBase], str], # noqa: ANN401 + obj: Any, # noqa: ANN401 + upload_file: Callable[[io.IOBase], str], ) -> Any: # noqa: ANN401 """ Return a JSON-compatible version of the object. diff --git a/replicate/version.py b/replicate/version.py index 6630d67f..dbba4423 100644 --- a/replicate/version.py +++ b/replicate/version.py @@ -30,7 +30,7 @@ class Version(BaseModel): openapi_schema: dict """An OpenAPI description of the model inputs and outputs.""" - def predict(self, **kwargs) -> Union[Any, Iterator[Any]]: + def predict(self, **kwargs) -> Union[Any, Iterator[Any]]: # noqa: ANN401 """ DEPRECATED: Use `replicate.run()` instead.