mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-05-06 22:12:12 +08:00
[Feature] Add Support For Python 3.14 (#7349)
* add support for Python 3.14 * escape % in argparse_translator in help strings * black * cli python version string * fix test param placeholder * fix integration_tests_testers * add 3.14 to ODP Desktop environment creation choices * partial lock update * update lock files * and the rest of the locks --------- Co-authored-by: deeleeramone <>
This commit is contained in:
@@ -3,7 +3,8 @@
|
||||
import argparse
|
||||
import os
|
||||
from pathlib import Path
|
||||
from typing import Literal, get_type_hints
|
||||
import inspect as _inspect
|
||||
from typing import Literal
|
||||
|
||||
import pytest
|
||||
import requests
|
||||
@@ -136,12 +137,11 @@ def write_commands_integration_tests(
|
||||
if not http_method:
|
||||
commands_not_found.append(route)
|
||||
else:
|
||||
hints = get_type_hints(cm_map[route])
|
||||
hints.pop("cc", None)
|
||||
hints.pop("return", None)
|
||||
sig = _inspect.signature(cm_map[route])
|
||||
param_names = [k for k in sig.parameters.keys() if k not in ("cc", "return")]
|
||||
|
||||
params_list = (
|
||||
[{k: "" for k in get_post_flat_params(hints)}]
|
||||
[{k: "" for k in param_names}]
|
||||
if http_method == "post"
|
||||
else get_test_params(
|
||||
model_name=cm_models[route], # type: ignore
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
import argparse
|
||||
from pathlib import Path, PosixPath
|
||||
import inspect as _inspect
|
||||
from typing import (
|
||||
Any,
|
||||
Literal,
|
||||
get_origin,
|
||||
get_type_hints,
|
||||
)
|
||||
|
||||
import pytest
|
||||
@@ -145,6 +145,16 @@ def get_test_params_data_processing(hints: dict[str, type]):
|
||||
return list(hints.keys())
|
||||
|
||||
|
||||
def get_params_from_signature(func) -> list[str]:
|
||||
"""Get parameter names from function signature.
|
||||
|
||||
Uses inspect.signature instead of get_type_hints for compatibility
|
||||
with Python 3.14+ (PEP 649 lazy annotation evaluation).
|
||||
"""
|
||||
sig = _inspect.signature(func)
|
||||
return list(sig.parameters.keys())
|
||||
|
||||
|
||||
def get_full_command_name_and_test_name(route: str) -> tuple[str, str]:
|
||||
"""Get the full command name and test name."""
|
||||
cmd_parts = route.split("/")
|
||||
@@ -217,10 +227,9 @@ def write_test_data_processing(
|
||||
if extension_name in route and route.startswith(f"/{extension_name}/"):
|
||||
test_name, full_command = get_full_command_name_and_test_name(route=route)
|
||||
|
||||
hints = get_type_hints(commands_map[route])
|
||||
hints.pop("cc", None)
|
||||
hints.pop("return", None)
|
||||
test_params_list = [{k: "" for k in get_test_params_data_processing(hints)}]
|
||||
param_names = get_params_from_signature(commands_map[route])
|
||||
param_names = [k for k in param_names if k not in ("cc", "return")]
|
||||
test_params_list = [{k: "" for k in param_names}]
|
||||
|
||||
write_to_file_w_template(
|
||||
test_file=test_file,
|
||||
|
||||
@@ -7,16 +7,12 @@ from collections.abc import Callable
|
||||
from typing import (
|
||||
Any,
|
||||
Literal,
|
||||
get_type_hints,
|
||||
)
|
||||
|
||||
from openbb_core.app.provider_interface import ProviderInterface
|
||||
from openbb_core.app.router import CommandMap
|
||||
|
||||
from .integration_tests_generator import (
|
||||
find_extensions,
|
||||
get_test_params_data_processing,
|
||||
)
|
||||
from .integration_tests_generator import find_extensions
|
||||
|
||||
|
||||
def get_integration_tests(
|
||||
@@ -263,9 +259,10 @@ def check_integration_tests(
|
||||
for route, _ in cm.map.items():
|
||||
for function in processing_functions:
|
||||
if route.replace("/", "_")[1:] == function.replace("test_", ""):
|
||||
hints = get_type_hints(cm.map[route])
|
||||
sig = inspect.signature(cm.map[route])
|
||||
param_names = list(sig.parameters.keys()) + ["return"]
|
||||
processing_command_params = [
|
||||
{k: "" for k in get_test_params_data_processing(hints)}
|
||||
{k: "" for k in param_names}
|
||||
]
|
||||
if (
|
||||
not processing_command_params
|
||||
|
||||
Reference in New Issue
Block a user