-
Notifications
You must be signed in to change notification settings - Fork 5k
[Bug] Python Error Fix β Type Hint Compatibility #249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,6 +1,7 @@ | ||||||
| from .alpha_vantage_common import _make_api_request, format_datetime_for_api | ||||||
| from typing import Union | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to the PEP 8 style guide, imports should be grouped in the following order: standard library, third-party, and then local application imports. To fix this, you would move this line above the import on line 1. Due to tooling limitations, I cannot provide an automated suggestion that spans both lines, but the correct order would be: from typing import Union
from .alpha_vantage_common import _make_api_request, format_datetime_for_api |
||||||
|
|
||||||
| def get_news(ticker, start_date, end_date) -> dict[str, str] | str: | ||||||
| def get_news(ticker, start_date, end_date) -> Union[dict[str, str], str]: | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function returns the raw string response from Additionally, to improve code clarity and maintainability, it's good practice to add type hints for the function's parameters.
Suggested change
|
||||||
| """Returns live and historical market news & sentiment data from premier news outlets worldwide. | ||||||
|
|
||||||
| Covers stocks, cryptocurrencies, forex, and topics like fiscal policy, mergers & acquisitions, IPOs. | ||||||
|
|
@@ -24,7 +25,7 @@ def get_news(ticker, start_date, end_date) -> dict[str, str] | str: | |||||
|
|
||||||
| return _make_api_request("NEWS_SENTIMENT", params) | ||||||
|
|
||||||
| def get_insider_transactions(symbol: str) -> dict[str, str] | str: | ||||||
| def get_insider_transactions(symbol: str) -> Union[dict[str, str], str]: | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to
Suggested change
|
||||||
| """Returns latest and historical insider transactions by key stakeholders. | ||||||
|
|
||||||
| Covers transactions by founders, executives, board members, etc. | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function implementation shows that it always returns
response_text, which is a string. It never returns a dictionary, as the JSON is only parsed to check for API errors before being discarded. Therefore, the return type hint should bestrinstead ofUnion[dict, str]to accurately reflect the function's behavior and prevent confusion for developers and static analysis tools.