Skip to content
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

fix "reportOptionalIterable" #2079

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions pyrightconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,5 @@
"reportReturnType": "warning",
"reportAssignmentType": "warning",
"reportOptionalSubscript": "warning",
"reportOptionalIterable": "warning",
"reportCallIssue": "warning",
"reportUnhashable": "warning"
}
9 changes: 5 additions & 4 deletions yfinance/scrapers/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def earnings_history(self) -> pd.DataFrame:

for key in data_dict.keys():
data_dict[key].append(item.get(key, {}).get('raw', None))

datetime_index = pd.to_datetime(quarters, format='%Y-%m-%d')
self._earnings_history = pd.DataFrame(data_dict, index=datetime_index)
return self._earnings_history
Expand Down Expand Up @@ -220,9 +220,10 @@ def growth_estimates(self) -> pd.DataFrame:
sector_trend = trends['sectorTrend']['estimates'] or dummy_trend
index_trend = trends['indexTrend']['estimates'] or dummy_trend

for item in self._earnings_trend:
period = item['period']
data_dict[period].append(item.get('growth', {}).get('raw', None))
if self._earnings_trend:
for item in self._earnings_trend:
period = item['period']
data_dict[period].append(item.get('growth', {}).get('raw', None))

for item in industry_trend:
period = item['period']
Expand Down
7 changes: 4 additions & 3 deletions yfinance/scrapers/quote.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,9 +607,10 @@ def _fetch_info(self, proxy):
)
# Most keys that appear in multiple dicts have same value. Except 'maxAge' because
# Yahoo not consistent with days vs seconds. Fix it here:
for k in query1_info:
if "maxAge" in query1_info[k] and query1_info[k]["maxAge"] == 1:
query1_info[k]["maxAge"] = 86400
if query1_info:
for k in query1_info:
if "maxAge" in query1_info[k] and query1_info[k]["maxAge"] == 1:
query1_info[k]["maxAge"] = 86400
query1_info = {
k1: v1
for k, v in query1_info.items()
Expand Down
Loading