[BugFix] Release fixes (#6560)

* Bump openbb version

* Small fixes

* update version

* Add python 3.12 to noxfile

* ^

* python 3.12 compatibility fixes

* fix typing

* fix currency snapshots

* black

* Enable test collection on 3.12

* Update mock called once assertion syntax

* remove logging assertion

* fix command runner chart assertion

---------

Co-authored-by: Theodore Aptekarev <aptekarev@gmail.com>
This commit is contained in:
montezdesousa
2024-07-02 20:33:11 +01:00
committed by GitHub
parent 5c1a1efa9a
commit ecede0b4e4
12 changed files with 49 additions and 26 deletions

View File

@@ -13,7 +13,7 @@ CLI_DIR = ROOT_DIR / "cli"
CLI_TESTS = CLI_DIR / "tests"
@nox.session(python=["3.9", "3.10", "3.11"])
@nox.session(python=["3.9", "3.10", "3.11", "3.12"])
def unit_test_platform(session):
"""Run the test suite."""
session.install("poetry", "toml")
@@ -31,7 +31,7 @@ def unit_test_platform(session):
)
@nox.session(python=["3.9", "3.10", "3.11"])
@nox.session(python=["3.9", "3.10", "3.11", "3.12"])
def unit_test_cli(session):
"""Run the test suite."""
session.install("poetry", "toml")

View File

@@ -19,7 +19,7 @@ jobs:
matrix:
python_version:
["3.9", "3.10", "3.11"]
["3.9", "3.10", "3.11", "3.12"]
steps:
- name: Checkout code
uses: actions/checkout@v4

View File

@@ -19,7 +19,7 @@ jobs:
matrix:
python_version:
["3.9", "3.10", "3.11"]
["3.9", "3.10", "3.11", "3.12"]
steps:
- name: Checkout code
uses: actions/checkout@v4

View File

@@ -57,7 +57,7 @@ def exception_handler(func: Callable[P, R]) -> Callable[P, R]:
while tb.tb_next is not None:
tb = tb.tb_next
if isinstance(e, ValidationError):
if isinstance(e, ValidationError) and "Data" not in e.title:
error_list = []
validation_error = f"{e.error_count()} validations error(s)"
for err in e.errors(include_url=False):

View File

@@ -254,14 +254,12 @@ def test_parameters_builder_build(mock_func, execution_context):
}
@patch("openbb_core.app.command_runner.LoggingService")
def test_command_runner(_):
def test_command_runner():
"""Test command runner."""
assert CommandRunner()
@patch("openbb_core.app.command_runner.LoggingService")
def test_command_runner_properties(mock_logging_service):
def test_command_runner_properties():
"""Test properties."""
sys = SystemSettings()
user = UserSettings()
@@ -272,7 +270,6 @@ def test_command_runner_properties(mock_logging_service):
assert runner.system_settings == sys
assert runner.user_settings == user
assert runner.command_map == cmd_map
assert mock_logging_service.called_once()
@patch("openbb_core.app.command_runner.LoggingService")
@@ -353,14 +350,14 @@ async def test_static_command_runner_execute_func(
mock_chart.return_value = None
result = await StaticCommandRunner._execute_func(
"mock/route", (1, 2, 3, 4), execution_context, mock_func, {}
"mock/route", (1, 2, 3, 4), execution_context, mock_func, {"chart": True}
)
assert result.results == [1, 2, 3, 4]
assert mock_logging_service.called_once()
assert mock_parameters_builder_build.called_once()
assert mock_command.called_once()
assert mock_chart.called_once()
mock_logging_service.assert_called_once()
mock_parameters_builder_build.assert_called_once()
mock_command.assert_called_once()
mock_chart.assert_called_once()
def test_static_command_runner_chart():

View File

@@ -139,7 +139,7 @@ def test_derivatives_futures_historical(params, headers):
{
"provider": "cboe",
"symbol": "VX_EOD",
"date": None,
"date": "2024-06-25",
}
),
],

View File

@@ -116,7 +116,7 @@ def test_derivatives_futures_historical(params, obb):
"params",
[
({"provider": "yfinance", "symbol": "ES", "date": None}),
({"provider": "cboe", "symbol": "VX", "date": None}),
({"provider": "cboe", "symbol": "VX", "date": "2024-06-25"}),
],
)
@pytest.mark.integration

View File

@@ -46,7 +46,7 @@ async def historical(
@router.command(
model="FuturesCurve",
examples=[
APIEx(parameters={"symbol": "VX", "provider": "cboe"}),
APIEx(parameters={"symbol": "VX", "provider": "cboe", "date": "2024-06-25"}),
APIEx(
description="Enter a date to get the term structure from a historical date.",
parameters={"symbol": "NG", "provider": "yfinance", "date": "2023-01-01"},

View File

@@ -9,10 +9,12 @@ import os
import re
from ast import AsyncFunctionDef, Call, FunctionDef, Name, parse, unparse
from dataclasses import dataclass
from importlib.metadata import entry_points
from importlib.metadata import EntryPoint, entry_points
from inspect import getmembers, isfunction
from typing import Any, Dict, List, Optional, Set, Tuple
from sys import version_info
from typing import Any, Dict, List, Optional, Set, Tuple, Union
from importlib_metadata import EntryPoints
from openbb_core.app.provider_interface import ProviderInterface
pi = ProviderInterface()
@@ -68,12 +70,18 @@ def check_docstring_examples() -> List[str]:
return errors
def filter_eps(eps: Union[EntryPoints, dict], group: str) -> Tuple[EntryPoint, ...]:
if version_info[:2] == (3, 12):
return eps.select(group=group) or () # type: ignore[union-attr]
return eps.get(group, ()) # type: ignore[union-attr]
def list_openbb_extensions() -> Tuple[Set[str], Set[str], Set[str]]:
"""List installed openbb extensions and providers.
Returns
-------
Tuple[Set[str], Set[str]]
Tuple[Set[str], Set[str], Set[str]]
First element: set of installed core extensions.
Second element: set of installed provider extensions.
Third element: set of installed obbject extensions.
@@ -82,15 +90,30 @@ def list_openbb_extensions() -> Tuple[Set[str], Set[str], Set[str]]:
core_extensions = set()
provider_extensions = set()
obbject_extensions = set()
entry_points_dict = entry_points()
for entry_point in entry_points_dict.get("openbb_core_extension", []):
# Compatibility for different Python versions
if hasattr(entry_points_dict, "select"): # Python 3.12+
core_entry_points = entry_points_dict.select(group="openbb_core_extension")
provider_entry_points = entry_points_dict.select(
group="openbb_provider_extension"
)
obbject_entry_points = entry_points_dict.select(
group="openbb_obbject_extension"
)
else:
core_entry_points = entry_points_dict.get("openbb_core_extension", [])
provider_entry_points = entry_points_dict.get("openbb_provider_extension", [])
obbject_entry_points = entry_points_dict.get("openbb_obbject_extension", [])
for entry_point in core_entry_points:
core_extensions.add(f"{entry_point.name}")
for entry_point in entry_points_dict.get("openbb_provider_extension", []):
for entry_point in provider_entry_points:
provider_extensions.add(f"{entry_point.name}")
for entry_point in entry_points_dict.get("openbb_obbject_extension", []):
for entry_point in obbject_entry_points:
obbject_extensions.add(f"{entry_point.name}")
return core_extensions, provider_extensions, obbject_extensions

View File

@@ -661,6 +661,7 @@ def test_charting_derivatives_futures_historical(params, obb):
{
"provider": "cboe",
"symbol": "VX",
"date": "2024-06-25",
}
),
],

View File

@@ -316,7 +316,7 @@ class IntrinioOptionsSnapshotsFetcher(
strike = f"{front}{_strike[0]}{_strike[1]}{back}"
return symbol + exp + cp + strike
if symbols.str.contains("\.").any(): # noqa # pylint: disable=W1401
if symbols.str.contains(r"\.").any(): # noqa # pylint: disable=W1401
df["contract_symbol"] = df["contract_symbol"].apply(apply_contract_symbol)
else:
df["contract_symbol"] = symbols.str.replace("_", "")

View File

@@ -177,7 +177,9 @@ class PolygonCurrencySnapshotsFetcher(
for item in filtered_data:
new_item = {}
new_item["base_currency"] = item.get("base_currency")
new_item["counter_currency"] = item.get("counter_currency")
new_item["counter_currency"] = item.get("counter_currency") or item.get(
"index"
)
new_item["change"] = item.get("todaysChange", None)
change_percent = item.get("todaysChangePerc", None)
new_item["change_percent"] = (