clan-cli: Ignore new type hints in api/serde.py

clan-cli: Ignore new type hints in api/serde.py

clan-cli: Ignore new type hints in api/serde.py

clan-cli: Ignore new type hints in api/serde.py
This commit is contained in:
Qubasa
2025-01-06 15:41:20 +01:00
parent 1b1fa8c71b
commit 63331a2a44
8 changed files with 27 additions and 24 deletions

View File

@@ -40,8 +40,7 @@ def open_file(
root.withdraw() # Hide the main window
root.attributes("-topmost", True) # Bring the dialogs to the front
file_path: str = ""
file_path: str = ""
multiple_files: list[str] = []
if file_request.mode == "open_file":
@@ -67,10 +66,10 @@ def open_file(
elif file_request.mode == "open_multiple_files":
tresult = filedialog.askopenfilenames(
title=file_request.title,
initialdir=file_request.initial_folder,
filetypes=_apply_filters(file_request.filters),
)
title=file_request.title,
initialdir=file_request.initial_folder,
filetypes=_apply_filters(file_request.filters),
)
multiple_files = list(tresult)
if len(file_path) == 0 and len(multiple_files) == 0:

View File

@@ -54,12 +54,14 @@ def update_wrapper_signature(wrapper: Callable, wrapped: Callable) -> None:
params = list(sig.parameters.values())
# Add 'op_key' parameter
op_key_param = Parameter("op_key",
Parameter.KEYWORD_ONLY,
# we add a None default value so that typescript code gen drops the parameter
# FIXME: this is a hack, we should filter out op_key in the typescript code gen
default=None,
annotation=str)
op_key_param = Parameter(
"op_key",
Parameter.KEYWORD_ONLY,
# we add a None default value so that typescript code gen drops the parameter
# FIXME: this is a hack, we should filter out op_key in the typescript code gen
default=None,
annotation=str,
)
params.append(op_key_param)
# Create a new signature

View File

@@ -302,7 +302,7 @@ def construct_dataclass(
field_value = data.get(data_field_name)
if field_value is None and (
field.type is None or is_type_in_union(field.type, type(None))
field.type is None or is_type_in_union(field.type, type(None)) # type: ignore
):
field_values[field.name] = None
else:

View File

@@ -119,7 +119,9 @@ def type_to_dict(
f.type, str
), f"Expected field type to be a type, got {f.type}, Have you imported `from __future__ import annotations`?"
properties[f.metadata.get("alias", f.name)] = type_to_dict(
f.type, f"{scope} {t.__name__}.{f.name}", type_map
f.type,
f"{scope} {t.__name__}.{f.name}", # type: ignore
type_map, # type: ignore
)
required = set()

View File

@@ -10,6 +10,6 @@ class ClanJSONEncoder(json.JSONEncoder):
return o.to_json()
# Check if the object is a dataclass
if dataclasses.is_dataclass(o):
return dataclasses.asdict(o) # type: ignore[call-overload]
return dataclasses.asdict(o) # type: ignore
# Otherwise, use the default serialization
return super().default(o)

View File

@@ -43,14 +43,18 @@ export interface GtkResponse<T> {
op_key: string;
}
export const callApi = async <K extends OperationNames>(
method: K,
args: OperationArgs<K>,
): Promise<OperationResponse<K>> => {
console.log("Calling API", method, args);
const response = await (window as unknown as Record<OperationNames, (args: OperationArgs<OperationNames>) => Promise<OperationResponse<OperationNames>>>)[method](args);
const response = await (
window as unknown as Record<
OperationNames,
(
args: OperationArgs<OperationNames>,
) => Promise<OperationResponse<OperationNames>>
>
)[method](args);
return response as OperationResponse<K>;
};

View File

@@ -26,7 +26,6 @@ export const client = new QueryClient();
const root = document.getElementById("app");
if (import.meta.env.DEV && !(root instanceof HTMLElement)) {
throw new Error(
"Root element not found. Did you forget to add it to your index.html? Or maybe the id attribute got misspelled?",

View File

@@ -1,9 +1,6 @@
import { describe, it } from "vitest";
describe.concurrent("API types work properly", () => {
// Test some basic types
it("distinct success/error unions", async () => {
});
it("distinct success/error unions", async () => {});
});