Skip to content

Commit 26d6cd1

Browse files
Make lint
1 parent 4d63293 commit 26d6cd1

8 files changed

Lines changed: 46 additions & 30 deletions

File tree

src/datacustomcode/cli.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ def deploy(
210210
):
211211
from datacustomcode.deploy import (
212212
COMPUTE_TYPES,
213-
CodeExtensionMetadata,
214213
USE_IN_FEATURE_MAPPING_FOR_CONNECT_API,
214+
CodeExtensionMetadata,
215215
deploy_full,
216216
infer_use_in_feature,
217217
)
@@ -255,7 +255,9 @@ def deploy(
255255
raise click.Abort()
256256

257257
# Map user-provided feature names to API names
258-
mapped_feature = USE_IN_FEATURE_MAPPING_FOR_CONNECT_API.get(use_in_feature, use_in_feature)
258+
mapped_feature = USE_IN_FEATURE_MAPPING_FOR_CONNECT_API.get(
259+
use_in_feature, use_in_feature
260+
)
259261
metadata.functionInvokeOptions = [mapped_feature]
260262

261263
try:
@@ -286,10 +288,7 @@ def init(directory: str, code_type: str, use_in_feature: Optional[str]):
286288
update_config,
287289
write_sdk_config,
288290
)
289-
from datacustomcode.template import (
290-
copy_function_template,
291-
copy_script_template,
292-
)
291+
from datacustomcode.template import copy_function_template, copy_script_template
293292

294293
click.echo("Copying template to " + click.style(directory, fg="blue", bold=True))
295294
if code_type == "script":
@@ -397,5 +396,10 @@ def run(
397396
from datacustomcode.run import run_entrypoint
398397

399398
run_entrypoint(
400-
entrypoint, config_file, dependencies, profile, test_file=test_with, sf_cli_org=sf_cli_org
399+
entrypoint,
400+
config_file,
401+
dependencies,
402+
profile,
403+
test_file=test_with,
404+
sf_cli_org=sf_cli_org,
401405
)

src/datacustomcode/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@
4242
REQUEST_TYPE_TO_FEATURE = {
4343
"SearchIndexChunkingV1Request": "SearchIndexChunking",
4444
"SearchIndexChunkingV1Response": "SearchIndexChunking",
45-
}
45+
}

src/datacustomcode/deploy.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@
3535
import requests
3636

3737
from datacustomcode.cmd import cmd_output
38-
from datacustomcode.constants import (
39-
REQUEST_TYPE_TO_FEATURE,
40-
USE_IN_FEATURE_MAPPING_FOR_CONNECT_API,
41-
)
38+
from datacustomcode.constants import REQUEST_TYPE_TO_FEATURE
4239
from datacustomcode.scan import find_base_directory, get_package_type
4340

4441
DATA_CUSTOM_CODE_PATH = "services/data/v63.0/ssot/data-custom-code"
@@ -85,7 +82,9 @@ def infer_use_in_feature(entrypoint_path: str) -> Union[str, None]:
8582
"""
8683
from datacustomcode.function_utils import inspect_function_types_static
8784

88-
request_type_name, response_type_name = inspect_function_types_static(entrypoint_path)
85+
request_type_name, response_type_name = inspect_function_types_static(
86+
entrypoint_path
87+
)
8988

9089
if not request_type_name or not response_type_name:
9190
return None

src/datacustomcode/function/feature_types/chunking.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
Any,
2323
Dict,
2424
List,
25-
Literal,
2625
)
2726

2827
from pydantic import BaseModel, Field
@@ -76,7 +75,10 @@ class SearchIndexChunkingV1Request(BaseModel):
7675

7776
class SearchIndexChunkingV1Response(BaseModel):
7877
"""Batch response for UDS chunking"""
78+
7979
output: List[SearchIndexChunkOutput] = Field(
8080
default_factory=list, description="Flat list of chunks from all docs"
8181
)
82-
status: SearchIndexStatusResponse = Field(..., description="Overall operation status")
82+
status: SearchIndexStatusResponse = Field(
83+
..., description="Overall operation status"
84+
)

src/datacustomcode/function_utils.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@
1919
import importlib.util
2020
import inspect
2121
import json
22-
import sys
2322
import typing
24-
from typing import Any, Optional, Tuple
23+
from typing import (
24+
Any,
25+
Optional,
26+
Tuple,
27+
)
2528

2629

2730
def load_function_module(entrypoint_path: str, module_name: str = "function_module"):
@@ -59,7 +62,7 @@ def get_function_callable(module):
5962
AttributeError: If module doesn't have a 'function' attribute
6063
"""
6164
if not hasattr(module, "function"):
62-
raise AttributeError(f"Module does not have a 'function' callable")
65+
raise AttributeError("Module does not have a 'function' callable")
6366
return module.function
6467

6568

@@ -108,7 +111,9 @@ def get_function_signature_types(
108111
return request_type, response_type, request_type_name, response_type_name
109112

110113

111-
def inspect_function_types_static(entrypoint_path: str) -> Tuple[Optional[str], Optional[str]]:
114+
def inspect_function_types_static(
115+
entrypoint_path: str,
116+
) -> Tuple[Optional[str], Optional[str]]:
112117
"""Inspect function types using static AST parsing (no imports).
113118
114119
This parses the Python file without executing it, so it doesn't
@@ -121,7 +126,7 @@ def inspect_function_types_static(entrypoint_path: str) -> Tuple[Optional[str],
121126
Tuple of (request_type_name, response_type_name)
122127
"""
123128
try:
124-
with open(entrypoint_path, 'r') as f:
129+
with open(entrypoint_path, "r") as f:
125130
tree = ast.parse(f.read(), filename=entrypoint_path)
126131

127132
# Find the 'function' definition
@@ -132,7 +137,9 @@ def inspect_function_types_static(entrypoint_path: str) -> Tuple[Optional[str],
132137
if node.args.args and len(node.args.args) > 0:
133138
first_param = node.args.args[0]
134139
if first_param.annotation:
135-
request_type_name = _get_type_name_from_ast(first_param.annotation)
140+
request_type_name = _get_type_name_from_ast(
141+
first_param.annotation
142+
)
136143

137144
# Get response type (return annotation)
138145
response_type_name = None
@@ -175,7 +182,7 @@ def _import_pydantic_model(entrypoint_path: str, type_name: str) -> Optional[Any
175182
The Pydantic model class, or None if not found
176183
"""
177184
try:
178-
with open(entrypoint_path, 'r') as f:
185+
with open(entrypoint_path, "r") as f:
179186
tree = ast.parse(f.read(), filename=entrypoint_path)
180187

181188
# Find where this type is imported from
@@ -344,12 +351,12 @@ def generate_test_json(entrypoint_path: str, output_path: str) -> None:
344351

345352
# Check if it's a Pydantic model
346353
if not hasattr(request_type, "model_fields"):
347-
raise ValueError(f"Request parameter type must be a Pydantic model")
354+
raise ValueError("Request parameter type must be a Pydantic model")
348355

349356
# Generate sample data for ALL fields (use defaults where available)
350357
sample_data = _generate_model_sample_data(request_type)
351358
sample_instance = request_type(**sample_data)
352359

353360
# Write to file
354361
with open(output_path, "w") as f:
355-
json.dump(sample_instance.model_dump(), f, indent=2)
362+
json.dump(sample_instance.model_dump(), f, indent=2)

src/datacustomcode/run.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,9 @@ def run_function_with_test(entrypoint: str, test_file: str) -> None:
177177
try:
178178
request = request_type(**test_data)
179179
except Exception as e:
180-
raise ValueError(f"Failed to parse test data as {request_type.__name__}: {e}") from e
180+
raise ValueError(
181+
f"Failed to parse test data as {request_type.__name__}: {e}"
182+
) from e
181183

182184
# Import Runtime
183185
from datacustomcode.function import Runtime

src/datacustomcode/template.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,12 @@ def copy_function_template(target_dir: str, use_in_feature: str) -> None:
6969
destination = os.path.join(target_dir, item)
7070

7171
if os.path.isdir(source):
72-
logger.debug(f"Copying feature-specific directory {source} to {destination}...")
72+
logger.debug(
73+
f"Copying feature-specific directory {source} to {destination}..."
74+
)
7375
shutil.copytree(source, destination, dirs_exist_ok=True)
7476
else:
75-
logger.debug(f"Copying feature-specific file {source} to {destination}...")
77+
logger.debug(
78+
f"Copying feature-specific file {source} to {destination}..."
79+
)
7680
shutil.copy2(source, destination)
77-
78-
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# Packages required for the chunking function
2-
langchain-text-splitters>=0.3.0
2+
langchain-text-splitters>=0.3.0

0 commit comments

Comments
 (0)