diff --git a/pyrightconfig.json b/pyrightconfig.json index 9b190104..08ff62b0 100644 --- a/pyrightconfig.json +++ b/pyrightconfig.json @@ -9,7 +9,5 @@ "reportReturnType": "warning", "reportAssignmentType": "warning", "reportOptionalSubscript": "warning", - "reportOptionalIterable": "warning", "reportCallIssue": "warning", - "reportUnhashable": "warning" } diff --git a/yfinance/scrapers/analysis.py b/yfinance/scrapers/analysis.py index f2778f28..5c66c423 100644 --- a/yfinance/scrapers/analysis.py +++ b/yfinance/scrapers/analysis.py @@ -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 @@ -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'] diff --git a/yfinance/scrapers/quote.py b/yfinance/scrapers/quote.py index a155c620..9854bdee 100644 --- a/yfinance/scrapers/quote.py +++ b/yfinance/scrapers/quote.py @@ -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()