Skip to content

Commit 4b131d2

Browse files
authored
Version bump and lint (#134)
* version bump 12 -> 13 and lint * info -> debug
1 parent 4ae17de commit 4b131d2

File tree

6 files changed

+128
-137
lines changed

6 files changed

+128
-137
lines changed

patchwork/app.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,13 @@ def list_option_callback(ctx: click.Context, param: click.Parameter, value: str
116116
)
117117
@click.option("patched_api_key", "--patched_api_key", help="API key to use with the patched.codes service.")
118118
def cli(
119-
log: str,
120-
patchflow: str,
121-
opts: list[str],
122-
config: str | None,
123-
output: str | None,
124-
data_format: str,
125-
patched_api_key: str | None
119+
log: str,
120+
patchflow: str,
121+
opts: list[str],
122+
config: str | None,
123+
output: str | None,
124+
data_format: str,
125+
patched_api_key: str | None,
126126
):
127127
if "::" in patchflow:
128128
module_path, _, patchflow_name = patchflow.partition("::")
@@ -185,7 +185,6 @@ def cli(
185185
logger.debug(f"Patchflow {patchflow} not found as a class in {module_path}")
186186
exit(1)
187187

188-
189188
try:
190189
repo = Repo(Path.cwd(), search_parent_directories=True)
191190
with PatchedClient(inputs.get("patched_api_key")).patched_telemetry(patchflow_name, repo, {}):

patchwork/common/client/patched.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
import atexit
22
import contextlib
3-
import os
4-
import pathlib
53
import socket
64
import sys
7-
from typing import List
85

96
import click
107
import requests
118
from git.repo.base import Repo
129
from requests import Response, Session
1310
from requests.adapters import DEFAULT_POOLBLOCK, HTTPAdapter
1411
from urllib3 import HTTPConnectionPool, HTTPSConnectionPool, PoolManager
15-
from pydantic import BaseModel
1612

1713
from patchwork.common.utils import get_current_branch
1814
from patchwork.logger import logger
@@ -162,12 +158,7 @@ def record_patchflow_run(self, patchflow: str, repo: Repo, inputs: dict) -> int
162158
response = self._post(
163159
url=self.url + "/v1/patchwork/",
164160
headers={"Authorization": f"Bearer {self.access_token}"},
165-
json={
166-
"url": repo.remotes.origin.url,
167-
"patchflow": patchflow,
168-
"branch": branch,
169-
"inputs": inputs
170-
}
161+
json={"url": repo.remotes.origin.url, "patchflow": patchflow, "branch": branch, "inputs": inputs},
171162
)
172163

173164
if response is None:
@@ -177,7 +168,7 @@ def record_patchflow_run(self, patchflow: str, repo: Repo, inputs: dict) -> int
177168
logger.error(f"Failed to record patchflow run with status code {response.status_code}, msg:{response.text}")
178169
return None
179170

180-
logger.info(f"Patchflow run recorded for {patchflow}")
171+
logger.debug(f"Patchflow run recorded for {patchflow}")
181172
return response.json()["id"]
182173

183174
def finish_record_patchflow_run(self, id: int, patchflow: str, repo: Repo) -> None:
@@ -188,7 +179,7 @@ def finish_record_patchflow_run(self, id: int, patchflow: str, repo: Repo) -> No
188179
"id": id,
189180
"url": repo.remotes.origin.url,
190181
"patchflow": patchflow,
191-
}
182+
},
192183
)
193184

194185
if response is None:
@@ -198,4 +189,4 @@ def finish_record_patchflow_run(self, id: int, patchflow: str, repo: Repo) -> No
198189
logger.error(f"Failed to finish patchflow run with status code {response.status_code}, msg:{response.text}")
199190
return
200191

201-
logger.info(f"Patchflow run finished for {id}")
192+
logger.debug(f"Patchflow run finished for {id}")

patchwork/common/utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
from chardet.universaldetector import UniversalDetector
88
from chromadb.api.types import Documents, EmbeddingFunction
99
from chromadb.utils import embedding_functions
10-
from typing_extensions import Callable
1110
from git import Head, Repo
11+
from typing_extensions import Callable
12+
1213
from patchwork.managed_files import HOME_FOLDER
1314

1415
_CLEANUP_FILES: set[Path] = set()
@@ -143,6 +144,7 @@ def get_embedding_function(inputs: dict) -> EmbeddingFunction[Documents]:
143144

144145
return embedding_function
145146

147+
146148
def get_current_branch(repo: Repo) -> Head:
147149
remote = repo.remote("origin")
148150
if repo.head.is_detached:
@@ -159,4 +161,4 @@ def get_current_branch(repo: Repo) -> Head:
159161
"Make sure repository is not in a detached HEAD state with additional commits."
160162
)
161163

162-
return from_branch
164+
return from_branch

patchwork/steps/CommitChanges/CommitChanges.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from pathlib import Path
33

44
import git
5-
from git import Head, Repo
5+
from git import Repo
66
from typing_extensions import Generator
77

88
from patchwork.common.utils import get_current_branch
@@ -21,7 +21,6 @@ def get_slug_from_remote_url(remote_url: str) -> str:
2121
return potential_slug.removesuffix(".git")
2222

2323

24-
2524
@contextlib.contextmanager
2625
def transitioning_branches(
2726
repo: Repo, branch_prefix: str, branch_suffix: str = "", force: bool = True

0 commit comments

Comments
 (0)