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:
@@ -40,8 +40,7 @@ def open_file(
|
|||||||
root.withdraw() # Hide the main window
|
root.withdraw() # Hide the main window
|
||||||
root.attributes("-topmost", True) # Bring the dialogs to the front
|
root.attributes("-topmost", True) # Bring the dialogs to the front
|
||||||
|
|
||||||
|
file_path: str = ""
|
||||||
file_path: str = ""
|
|
||||||
multiple_files: list[str] = []
|
multiple_files: list[str] = []
|
||||||
|
|
||||||
if file_request.mode == "open_file":
|
if file_request.mode == "open_file":
|
||||||
@@ -67,10 +66,10 @@ def open_file(
|
|||||||
|
|
||||||
elif file_request.mode == "open_multiple_files":
|
elif file_request.mode == "open_multiple_files":
|
||||||
tresult = filedialog.askopenfilenames(
|
tresult = filedialog.askopenfilenames(
|
||||||
title=file_request.title,
|
title=file_request.title,
|
||||||
initialdir=file_request.initial_folder,
|
initialdir=file_request.initial_folder,
|
||||||
filetypes=_apply_filters(file_request.filters),
|
filetypes=_apply_filters(file_request.filters),
|
||||||
)
|
)
|
||||||
multiple_files = list(tresult)
|
multiple_files = list(tresult)
|
||||||
|
|
||||||
if len(file_path) == 0 and len(multiple_files) == 0:
|
if len(file_path) == 0 and len(multiple_files) == 0:
|
||||||
|
|||||||
@@ -54,12 +54,14 @@ def update_wrapper_signature(wrapper: Callable, wrapped: Callable) -> None:
|
|||||||
params = list(sig.parameters.values())
|
params = list(sig.parameters.values())
|
||||||
|
|
||||||
# Add 'op_key' parameter
|
# Add 'op_key' parameter
|
||||||
op_key_param = Parameter("op_key",
|
op_key_param = Parameter(
|
||||||
Parameter.KEYWORD_ONLY,
|
"op_key",
|
||||||
# we add a None default value so that typescript code gen drops the parameter
|
Parameter.KEYWORD_ONLY,
|
||||||
# FIXME: this is a hack, we should filter out op_key in the typescript code gen
|
# we add a None default value so that typescript code gen drops the parameter
|
||||||
default=None,
|
# FIXME: this is a hack, we should filter out op_key in the typescript code gen
|
||||||
annotation=str)
|
default=None,
|
||||||
|
annotation=str,
|
||||||
|
)
|
||||||
params.append(op_key_param)
|
params.append(op_key_param)
|
||||||
|
|
||||||
# Create a new signature
|
# Create a new signature
|
||||||
|
|||||||
@@ -302,7 +302,7 @@ def construct_dataclass(
|
|||||||
field_value = data.get(data_field_name)
|
field_value = data.get(data_field_name)
|
||||||
|
|
||||||
if field_value is None and (
|
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
|
field_values[field.name] = None
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -119,7 +119,9 @@ def type_to_dict(
|
|||||||
f.type, str
|
f.type, str
|
||||||
), f"Expected field type to be a type, got {f.type}, Have you imported `from __future__ import annotations`?"
|
), 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(
|
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()
|
required = set()
|
||||||
|
|||||||
@@ -10,6 +10,6 @@ class ClanJSONEncoder(json.JSONEncoder):
|
|||||||
return o.to_json()
|
return o.to_json()
|
||||||
# Check if the object is a dataclass
|
# Check if the object is a dataclass
|
||||||
if dataclasses.is_dataclass(o):
|
if dataclasses.is_dataclass(o):
|
||||||
return dataclasses.asdict(o) # type: ignore[call-overload]
|
return dataclasses.asdict(o) # type: ignore
|
||||||
# Otherwise, use the default serialization
|
# Otherwise, use the default serialization
|
||||||
return super().default(o)
|
return super().default(o)
|
||||||
|
|||||||
@@ -43,14 +43,18 @@ export interface GtkResponse<T> {
|
|||||||
op_key: string;
|
op_key: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const callApi = async <K extends OperationNames>(
|
export const callApi = async <K extends OperationNames>(
|
||||||
method: K,
|
method: K,
|
||||||
args: OperationArgs<K>,
|
args: OperationArgs<K>,
|
||||||
): Promise<OperationResponse<K>> => {
|
): Promise<OperationResponse<K>> => {
|
||||||
console.log("Calling API", method, args);
|
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>;
|
return response as OperationResponse<K>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ export const client = new QueryClient();
|
|||||||
|
|
||||||
const root = document.getElementById("app");
|
const root = document.getElementById("app");
|
||||||
|
|
||||||
|
|
||||||
if (import.meta.env.DEV && !(root instanceof HTMLElement)) {
|
if (import.meta.env.DEV && !(root instanceof HTMLElement)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
"Root element not found. Did you forget to add it to your index.html? Or maybe the id attribute got misspelled?",
|
"Root element not found. Did you forget to add it to your index.html? Or maybe the id attribute got misspelled?",
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
import { describe, it } from "vitest";
|
import { describe, it } from "vitest";
|
||||||
|
|
||||||
|
|
||||||
describe.concurrent("API types work properly", () => {
|
describe.concurrent("API types work properly", () => {
|
||||||
// Test some basic types
|
// Test some basic types
|
||||||
it("distinct success/error unions", async () => {
|
it("distinct success/error unions", async () => {});
|
||||||
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user