Skip to content

Commit

Permalink
Merge branch 'develop' into bugfix/remove-xlsx-export-from-cli-tables
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorWounds authored May 21, 2024
2 parents b316b2d + 1994b34 commit 584e6e0
Show file tree
Hide file tree
Showing 67 changed files with 1,658 additions and 1,482 deletions.
10 changes: 6 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ repos:
- id: check-merge-conflict
- id: detect-private-key
- repo: https://github.com/psf/black
rev: 24.1.0
rev: 24.4.2
hooks:
- id: black
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.285"
rev: "v0.4.4"
hooks:
- id: ruff
- repo: https://github.com/pycqa/pydocstyle
Expand All @@ -26,7 +26,7 @@ repos:
entry: pydocstyle
language: python
types: [python]
files: '^openbb_platform/.*\.py$'
files: '^(openbb_platform/|cli/).*\.py$'
exclude: 'tests/.*\.py|openbb_platform/test_.*\.py'
args: ["--config=ruff.toml"]
- repo: https://github.com/codespell-project/codespell
Expand All @@ -41,7 +41,8 @@ repos:
"--skip=./**/tests/**,./**/test_*.py,.git,*.css,*.csv,*.html,*.ini,*.ipynb,*.js,*.json,*.lock,*.scss,*.txt,*.yaml,build/pyinstaller/*,./website/config.toml",
"-x=.github/workflows/general-linting.yml"
]
- repo: local
- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.6.1"
hooks:
- id: mypy
name: mypy
Expand All @@ -50,6 +51,7 @@ repos:
language: python
"types_or": [python, pyi]
args: ["--ignore-missing-imports", "--scripts-are-modules", "--check-untyped-defs"]
additional_dependencies: ["types-requests", "types-setuptools"]
require_serial: true
- repo: https://github.com/kynan/nbstripout
rev: 0.6.1
Expand Down
243 changes: 118 additions & 125 deletions cli/poetry.lock

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions openbb_platform/core/openbb_core/app/command_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def get_polished_func(func: Callable) -> Callable:
def merge_args_and_kwargs(
cls,
func: Callable,
args: Tuple[Any],
args: Tuple[Any, ...],
kwargs: Dict[str, Any],
) -> Dict[str, Any]:
"""Merge args and kwargs into a single dict."""
Expand Down Expand Up @@ -134,7 +134,7 @@ def _needs_provider(func: Callable) -> bool:

def _has_provider(kwargs: Dict[str, Any]) -> bool:
"""Check if the kwargs already have a provider."""
provider_choices = kwargs.get("provider_choices", None)
provider_choices = kwargs.get("provider_choices")

if isinstance(provider_choices, dict): # when in python
return provider_choices.get("provider", None) is not None
Expand All @@ -156,7 +156,7 @@ def _get_default_provider(
Either pick it from the user defaults or from the command coverage.
"""
cmd_cov_given_route = command_coverage.get(route, None)
cmd_cov_given_route = command_coverage.get(route)
command_cov_provider = (
cmd_cov_given_route[0] if cmd_cov_given_route else None
)
Expand Down Expand Up @@ -293,9 +293,7 @@ async def _command(
) -> OBBject:
"""Run a command and return the output."""
obbject = await maybe_coroutine(func, **kwargs)
obbject.provider = getattr(
kwargs.get("provider_choices", None), "provider", None
)
obbject.provider = getattr(kwargs.get("provider_choices"), "provider", None)
return obbject

@classmethod
Expand Down
2 changes: 1 addition & 1 deletion openbb_platform/core/openbb_core/app/model/api_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class APISettings(BaseModel):

version: str = "1"
title: str = "OpenBB Platform API"
description: str = "This is the OpenBB Platform API."
description: str = "Investment research for everyone, anywhere."
terms_of_service: str = "http://example.com/terms/"
contact_name: str = "OpenBB Team"
contact_url: str = "https://openbb.co"
Expand Down
2 changes: 1 addition & 1 deletion openbb_platform/core/openbb_core/app/model/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def prepare(
def from_obbject(self) -> None:
"""Load credentials from OBBject extensions."""
self.credentials["obbject"] = set()
for name, entry in ExtensionLoader().obbject_objects.items():
for name, entry in ExtensionLoader().obbject_objects.items(): # type: ignore[attr-defined]
try:
for c in entry.credentials:
self.credentials["obbject"].add(c)
Expand Down
2 changes: 1 addition & 1 deletion openbb_platform/core/openbb_core/app/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ def from_extensions() -> Router:
"""Load routes from extensions."""
router = Router()

for name, entry in ExtensionLoader().core_objects.items():
for name, entry in ExtensionLoader().core_objects.items(): # type: ignore[attr-defined]
try:
router.include_router(router=entry, prefix=f"/{name}")
except Exception as e:
Expand Down
12 changes: 7 additions & 5 deletions openbb_platform/core/openbb_core/app/static/package_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def _save_reference_file(self, ext_map: Optional[Dict[str, List[str]]] = None):
"openbb": VERSION.replace("dev", ""),
"info": {
"title": "OpenBB Platform (Python)",
"description": "This is the OpenBB Platform (Python).",
"description": "Investment research for everyone, anywhere.",
"core": CORE_VERSION.replace("dev", ""),
"extensions": ext_map,
},
Expand Down Expand Up @@ -1048,7 +1048,7 @@ def generate_model_docstring(
cls,
model_name: str,
summary: str,
explicit_params: dict,
explicit_params: Dict[str, Parameter],
kwarg_params: dict,
returns: Dict[str, FieldInfo],
results_type: str,
Expand All @@ -1071,8 +1071,10 @@ def format_description(description: str) -> str:
description = description.replace("\n", f"\n{create_indent(2)}")
return description

def get_param_info(parameter: Parameter) -> Tuple[str, str]:
def get_param_info(parameter: Optional[Parameter]) -> Tuple[str, str]:
"""Get the parameter info."""
if not parameter:
return "", ""
annotation = getattr(parameter, "_annotation", None)
if isinstance(annotation, _AnnotatedAlias):
args = getattr(annotation, "__args__", []) if annotation else []
Expand Down Expand Up @@ -1123,7 +1125,7 @@ def get_param_info(parameter: Parameter) -> Tuple[str, str]:
docstring += "\n"
docstring += f"{create_indent(2)}Returns\n"
docstring += f"{create_indent(2)}-------\n"
providers, _ = get_param_info(explicit_params.get("provider", None))
providers, _ = get_param_info(explicit_params.get("provider"))
docstring += cls.get_OBBject_description(results_type, providers)

# Schema
Expand Down Expand Up @@ -1300,7 +1302,7 @@ def build_path_list(route_map: Dict[str, BaseRoute]) -> List[str]:
@staticmethod
def get_route(path: str, route_map: Dict[str, BaseRoute]):
"""Get the route from the path."""
return route_map.get(path, None)
return route_map.get(path)

@staticmethod
def get_child_path_list(path: str, path_list: List[str]) -> List[str]:
Expand Down
2 changes: 1 addition & 1 deletion openbb_platform/core/openbb_core/provider/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def from_extensions() -> Registry:
"""Load providers from entry points."""
registry = Registry()

for name, entry in ExtensionLoader().provider_objects.items():
for name, entry in ExtensionLoader().provider_objects.items(): # type: ignore[attr-defined]
try:
registry.include_provider(provider=entry)
except Exception as e:
Expand Down
2 changes: 1 addition & 1 deletion openbb_platform/core/openbb_core/provider/utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
)

import requests
from anyio import start_blocking_portal
from anyio.from_thread import start_blocking_portal
from typing_extensions import ParamSpec

from openbb_core.provider.abstract.data import Data
Expand Down
Loading

0 comments on commit 584e6e0

Please sign in to comment.