mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-27 12:40:35 +00:00
[Feature] Remove Python 3.9 (#7235)
* remove python 3.9 support and code * black * more cli lint * more linting * more lint * fix for tests * docstring grammar police * add lock to to build function to avoid async import race conditions * grammar police * lots more linting * relock
This commit is contained in:
@@ -6,51 +6,42 @@ import nox
|
||||
|
||||
ROOT_DIR = Path(__file__).parent.parent.parent
|
||||
PLATFORM_DIR = ROOT_DIR / "openbb_platform"
|
||||
PLATFORM_TESTS = [
|
||||
str(PLATFORM_DIR / p) for p in ["tests", "core", "providers", "extensions"]
|
||||
]
|
||||
PLATFORM_TESTS = [str(PLATFORM_DIR / p) for p in ["tests", "core", "providers", "extensions"]]
|
||||
CLI_DIR = ROOT_DIR / "cli"
|
||||
CLI_TESTS = CLI_DIR / "tests"
|
||||
|
||||
|
||||
@nox.session(python=["3.9", "3.10", "3.11", "3.12", "3.13"])
|
||||
@nox.session(python=["3.10", "3.11", "3.12", "3.13"])
|
||||
def unit_test_platform(session):
|
||||
"""Run the test suite."""
|
||||
session.install("poetry", "toml")
|
||||
session.install("poetry")
|
||||
session.run(
|
||||
"python",
|
||||
str(PLATFORM_DIR / "dev_install.py"),
|
||||
"-e",
|
||||
"all",
|
||||
external=True,
|
||||
)
|
||||
session.install("pytest")
|
||||
session.install("pytest-cov")
|
||||
|
||||
# Determine if we should ignore mcp_server tests based on Python version
|
||||
ignore_args = []
|
||||
if session.python == "3.9":
|
||||
ignore_args = ["--ignore=" + str(PLATFORM_DIR / "extensions/mcp_server/tests")]
|
||||
|
||||
session.run(
|
||||
"pytest",
|
||||
*PLATFORM_TESTS,
|
||||
*ignore_args,
|
||||
f"--cov={PLATFORM_DIR}",
|
||||
"-m",
|
||||
"not integration",
|
||||
)
|
||||
|
||||
|
||||
@nox.session(python=["3.9", "3.10", "3.11", "3.12", "3.13"])
|
||||
@nox.session(python=["3.10", "3.11", "3.12", "3.13"])
|
||||
def unit_test_cli(session):
|
||||
"""Run the test suite."""
|
||||
session.install("poetry", "toml")
|
||||
session.install("poetry")
|
||||
session.run(
|
||||
"python",
|
||||
str(PLATFORM_DIR / "dev_install.py"),
|
||||
"-e",
|
||||
"all",
|
||||
"--cli",
|
||||
external=True,
|
||||
)
|
||||
session.install("pytest")
|
||||
|
||||
@@ -29,19 +29,9 @@ def process_changelog(file_path, release_pr_number):
|
||||
pr_occurrences[pr_number].append(i)
|
||||
|
||||
# Set of indices to remove: includes all but last occurrence of each PR number
|
||||
to_remove = {
|
||||
i
|
||||
for pr, indices in pr_occurrences.items()
|
||||
if len(indices) > 1
|
||||
for i in indices[:-1]
|
||||
}
|
||||
to_remove = {i for pr, indices in pr_occurrences.items() if len(indices) > 1 for i in indices[:-1]}
|
||||
# Also remove any PR entries less than or equal to the specified release PR number
|
||||
to_remove.update(
|
||||
i
|
||||
for pr, indices in pr_occurrences.items()
|
||||
for i in indices
|
||||
if pr <= release_pr_number
|
||||
)
|
||||
to_remove.update(i for pr, indices in pr_occurrences.items() for i in indices if pr <= release_pr_number)
|
||||
|
||||
# Filter out lines marked for removal
|
||||
processed_lines = [line for i, line in enumerate(lines) if i not in to_remove]
|
||||
@@ -49,9 +39,7 @@ def process_changelog(file_path, release_pr_number):
|
||||
# Final sweep: Ensure no missed duplicates, keeping only the last occurrence
|
||||
final_lines = []
|
||||
seen_pr_numbers = set() # Track seen PR numbers to identify duplicates
|
||||
for line in reversed(
|
||||
processed_lines
|
||||
): # Start from the end to keep the last occurrence
|
||||
for line in reversed(processed_lines): # Start from the end to keep the last occurrence
|
||||
match = re.search(r"\(#(\d+)\)", line)
|
||||
if match:
|
||||
pr_number = int(match.group(1))
|
||||
@@ -72,9 +60,7 @@ def process_changelog(file_path, release_pr_number):
|
||||
if __name__ == "__main__":
|
||||
# Ensure correct command line arguments
|
||||
if len(sys.argv) < 3:
|
||||
logging.error(
|
||||
"Usage: python process_changelog.py <changelog_file> <release_pr_number>"
|
||||
)
|
||||
logging.error("Usage: python process_changelog.py <changelog_file> <release_pr_number>")
|
||||
sys.exit(1)
|
||||
|
||||
file_path = sys.argv[1]
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
import logging
|
||||
import re
|
||||
import sys
|
||||
from typing import Dict
|
||||
|
||||
import requests
|
||||
|
||||
@@ -24,12 +23,10 @@ def fetch_pr_details(owner: str, repo: str, pr_number: str, github_token: str) -
|
||||
return {}
|
||||
|
||||
|
||||
def parse_and_fetch_pr_details(
|
||||
markdown_text: str, owner: str, repo: str, github_token: str
|
||||
) -> Dict[str, str]:
|
||||
def parse_and_fetch_pr_details(markdown_text: str, owner: str, repo: str, github_token: str) -> dict[str, str]:
|
||||
"""Parse the markdown text and fetch details of PRs mentioned in the text."""
|
||||
sections = re.split(r"\n## ", markdown_text)
|
||||
categories: Dict[str, str] = {}
|
||||
categories: dict[str, str] = {}
|
||||
|
||||
for section in sections:
|
||||
split_section = section.split("\n", 1)
|
||||
@@ -49,9 +46,7 @@ def parse_and_fetch_pr_details(
|
||||
"body": re.sub(r"\s+", " ", pr_details["body"].strip()).strip(),
|
||||
}
|
||||
except Exception as e:
|
||||
logging.error(
|
||||
"Failed to fetch PR details for PR #%s: %s", pr_number, e
|
||||
)
|
||||
logging.error("Failed to fetch PR details for PR #%s: %s", pr_number, e)
|
||||
if category_name in categories:
|
||||
categories[category_name].append(pr_info) # type: ignore
|
||||
else:
|
||||
@@ -60,9 +55,7 @@ def parse_and_fetch_pr_details(
|
||||
return categories
|
||||
|
||||
|
||||
def insert_summary_into_markdown(
|
||||
markdown_text: str, category_name: str, summary: str
|
||||
) -> str:
|
||||
def insert_summary_into_markdown(markdown_text: str, category_name: str, summary: str) -> str:
|
||||
"""Insert a summary into the markdown text directly under the specified category name."""
|
||||
marker = f"## {category_name}"
|
||||
if marker in markdown_text:
|
||||
@@ -73,12 +66,7 @@ def insert_summary_into_markdown(
|
||||
if newline_pos != -1:
|
||||
# Insert the summary right after the newline that follows the category name
|
||||
# Ensuring it's on a new line and followed by two newlines before any subsequent content
|
||||
updated_markdown = (
|
||||
markdown_text[: newline_pos + 1]
|
||||
+ "\n"
|
||||
+ summary
|
||||
+ markdown_text[newline_pos + 1 :]
|
||||
)
|
||||
updated_markdown = markdown_text[: newline_pos + 1] + "\n" + summary + markdown_text[newline_pos + 1 :]
|
||||
else:
|
||||
# If there's no newline (e.g., end of file), just append the summary
|
||||
updated_markdown = markdown_text + "\n\n" + summary + "\n"
|
||||
@@ -144,9 +132,7 @@ def summarize_changelog_v2(
|
||||
]
|
||||
)
|
||||
summary = summarize_text_with_openai(aggregated_text, openai_api_key)
|
||||
updated_markdown = insert_summary_into_markdown(
|
||||
updated_markdown, category_of_interest, summary
|
||||
)
|
||||
updated_markdown = insert_summary_into_markdown(updated_markdown, category_of_interest, summary)
|
||||
|
||||
with open(changelog_v2, "w") as file:
|
||||
logging.info("Writing updated file: %s", changelog_v2)
|
||||
@@ -155,9 +141,7 @@ def summarize_changelog_v2(
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 3:
|
||||
logging.error(
|
||||
"Usage: python summarize_changelog.py <github_token> <openai_api_key>"
|
||||
)
|
||||
logging.error("Usage: python summarize_changelog.py <github_token> <openai_api_key>")
|
||||
sys.exit(1)
|
||||
|
||||
token = sys.argv[1]
|
||||
|
||||
2
.github/workflows/test-unit-cli.yml
vendored
2
.github/workflows/test-unit-cli.yml
vendored
@@ -21,7 +21,7 @@ jobs:
|
||||
|
||||
matrix:
|
||||
python_version:
|
||||
["3.9", "3.10", "3.11", "3.12", "3.13"]
|
||||
["3.10", "3.11", "3.12", "3.13"]
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
2
.github/workflows/test-unit-platform.yml
vendored
2
.github/workflows/test-unit-platform.yml
vendored
@@ -21,7 +21,7 @@ jobs:
|
||||
|
||||
matrix:
|
||||
python_version:
|
||||
["3.9", "3.10", "3.11", "3.12", "3.13"]
|
||||
["3.10", "3.11", "3.12", "3.13"]
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
Reference in New Issue
Block a user