Skip to content

Commit dcf22f1

Browse files
chore: fix tests and linting errors
1 parent 2c3287a commit dcf22f1

File tree

16 files changed

+346
-338
lines changed

16 files changed

+346
-338
lines changed

nasdaq_data_link_mcp_os/config.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@ def initialize_api():
1010

1111
api_key = os.getenv("NASDAQ_DATA_LINK_API_KEY")
1212
if not api_key:
13-
raise ValueError("NASDAQ_DATA_LINK_API_KEY environment variable is not set.")
13+
# Log warning but don't raise - API key required when using tools
14+
import warnings
15+
16+
warnings.warn(
17+
"NASDAQ_DATA_LINK_API_KEY environment variable is not set.", stacklevel=2
18+
)
19+
return False
1420

1521
# Set the API key directly on the module
1622
nasdaqdatalink.read_key(api_key)
23+
return True

nasdaq_data_link_mcp_os/resources/common/countries.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
import pycountry
44

5-
CountryCode = TypeVar('CountryCode', bound=str)
5+
CountryCode = TypeVar("CountryCode", bound=str)
6+
67

78
def get_country_code(country_name: str) -> str:
89
"""
@@ -17,11 +18,17 @@ def get_country_code(country_name: str) -> str:
1718
# Try fuzzy search
1819
name_lower = country_name.lower()
1920
for country in pycountry.countries:
20-
if (name_lower in country.name.lower() or
21-
(hasattr(country, 'common_name') and
22-
name_lower in country.common_name.lower()) or
23-
(hasattr(country, 'official_name') and
24-
name_lower in country.official_name.lower())):
21+
if (
22+
name_lower in country.name.lower()
23+
or (
24+
hasattr(country, "common_name")
25+
and name_lower in country.common_name.lower()
26+
)
27+
or (
28+
hasattr(country, "official_name")
29+
and name_lower in country.official_name.lower()
30+
)
31+
):
2532
return country.alpha_3
2633

2734
return f"Unknown country: {country_name}"

nasdaq_data_link_mcp_os/resources/equities_360/balance_sheet.py

Lines changed: 36 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def get_balance_sheet(
88
symbol: str | None = None,
99
figi: str | None = None,
1010
calendardate: str | None = None,
11-
dimension: str | None = None
11+
dimension: str | None = None,
1212
) -> pd.DataFrame | str:
1313
"""
1414
Fetch balance sheet data from Nasdaq Data Link E360 NDAQ/BS table.
@@ -37,7 +37,7 @@ def get_balance_sheet(
3737
params["dimension"] = dimension
3838

3939
# Fetch data from NDAQ/BS table
40-
data = nasdaqdatalink.get_table('NDAQ/BS', **params)
40+
data = nasdaqdatalink.get_table("NDAQ/BS", **params)
4141

4242
if data.empty:
4343
return "No data found for the specified criteria."
@@ -60,28 +60,28 @@ def list_available_balance_sheet_fields() -> list[dict[str, Any]]:
6060
"description": "The Calendar Date represents the normalized reportperiod",
6161
"type": "Date",
6262
"filterable": True,
63-
"primary_key": True
63+
"primary_key": True,
6464
},
6565
{
6666
"name": "symbol",
6767
"description": "Symbol of the company",
6868
"type": "String",
6969
"filterable": True,
70-
"primary_key": True
70+
"primary_key": True,
7171
},
7272
{
7373
"name": "figi",
7474
"description": "Unique Identifier given by Bloomberg",
7575
"type": "String",
76-
"filterable": True
76+
"filterable": True,
7777
},
7878
{
7979
"name": "reportperiod",
8080
"description": (
8181
"The Report Period represents the end date of the fiscal period"
8282
),
8383
"type": "Date",
84-
"primary_key": True
84+
"primary_key": True,
8585
},
8686
{
8787
"name": "dimension",
@@ -91,154 +91,142 @@ def list_available_balance_sheet_fields() -> list[dict[str, Any]]:
9191
),
9292
"type": "String",
9393
"filterable": True,
94-
"primary_key": True
94+
"primary_key": True,
9595
},
9696
{
9797
"name": "assets",
9898
"description": "Total assets recognized on the balance sheet",
99-
"type": "BigInt"
99+
"type": "BigInt",
100100
},
101101
{
102102
"name": "bvps",
103103
"description": "Book Value Per Share (ratio between equity and shareswa)",
104-
"type": "Double"
104+
"type": "Double",
105105
},
106106
{
107107
"name": "cashneq",
108108
"description": "Cash and equivalents on hand",
109-
"type": "BigInt"
109+
"type": "BigInt",
110110
},
111111
{
112112
"name": "debt",
113113
"description": "Total current and non-current debt",
114-
"type": "BigInt"
114+
"type": "BigInt",
115115
},
116116
{
117117
"name": "liabilities",
118118
"description": "Total liabilities recognized on the balance sheet",
119-
"type": "BigInt"
119+
"type": "BigInt",
120120
},
121121
{
122122
"name": "equity",
123123
"description": "Total stockholders' equity",
124-
"type": "BigInt"
124+
"type": "BigInt",
125125
},
126126
{
127127
"name": "accoci",
128128
"description": "Accumulated other comprehensive income",
129-
"type": "BigInt"
129+
"type": "BigInt",
130130
},
131131
{
132132
"name": "currency",
133133
"description": "The company functional reporting currency",
134-
"type": "String"
134+
"type": "String",
135135
},
136136
{
137137
"name": "investmentsnc",
138138
"description": "Non-current portion of investments",
139-
"type": "BigInt"
139+
"type": "BigInt",
140140
},
141141
{
142142
"name": "investmentsc",
143143
"description": "Current portion of investments",
144-
"type": "BigInt"
144+
"type": "BigInt",
145145
},
146146
{
147147
"name": "receivables",
148148
"description": "Trade and non-trade receivables",
149-
"type": "BigInt"
149+
"type": "BigInt",
150150
},
151151
{
152152
"name": "inventory",
153153
"description": "Inventory expected to be sold within one year",
154-
"type": "BigInt"
155-
},
156-
{
157-
"name": "assetsnc",
158-
"description": "Non-current assets",
159-
"type": "BigInt"
160-
},
161-
{
162-
"name": "assetsc",
163-
"description": "Current assets",
164-
"type": "BigInt"
154+
"type": "BigInt",
165155
},
156+
{"name": "assetsnc", "description": "Non-current assets", "type": "BigInt"},
157+
{"name": "assetsc", "description": "Current assets", "type": "BigInt"},
166158
{
167159
"name": "investments",
168160
"description": (
169161
"Total marketable and non-marketable securities and other "
170162
"invested assets"
171163
),
172-
"type": "BigInt"
164+
"type": "BigInt",
173165
},
174166
{
175167
"name": "ppnenet",
176168
"description": "Property, plant, and equipment (net of depreciation)",
177-
"type": "BigInt"
169+
"type": "BigInt",
178170
},
179171
{
180172
"name": "intangibles",
181173
"description": "Intangible assets and goodwill",
182-
"type": "BigInt"
174+
"type": "BigInt",
183175
},
184176
{
185177
"name": "tangibles",
186178
"description": "Tangible assets (assets minus intangibles)",
187-
"type": "BigInt"
179+
"type": "BigInt",
188180
},
189181
{
190182
"name": "payables",
191183
"description": "Trade and non-trade payables",
192-
"type": "BigInt"
184+
"type": "BigInt",
193185
},
194186
{
195187
"name": "liabilitiesnc",
196188
"description": "Non-current liabilities",
197-
"type": "BigInt"
189+
"type": "BigInt",
198190
},
199191
{
200192
"name": "liabilitiesc",
201193
"description": "Current liabilities",
202-
"type": "BigInt"
203-
},
204-
{
205-
"name": "debtc",
206-
"description": "Current portion of debt",
207-
"type": "BigInt"
194+
"type": "BigInt",
208195
},
196+
{"name": "debtc", "description": "Current portion of debt", "type": "BigInt"},
209197
{
210198
"name": "debtnc",
211199
"description": "Non-current portion of debt",
212-
"type": "BigInt"
200+
"type": "BigInt",
213201
},
214202
{
215203
"name": "deferredrev",
216204
"description": (
217205
"Deferred revenue (unrecognized revenue from received payments)"
218206
),
219-
"type": "BigInt"
207+
"type": "BigInt",
220208
},
221209
{
222210
"name": "retearn",
223211
"description": (
224212
"Retained earnings (cumulative undistributed earnings/deficit)"
225213
),
226-
"type": "BigInt"
214+
"type": "BigInt",
227215
},
228216
{
229217
"name": "taxassets",
230218
"description": "Tax assets and receivables",
231-
"type": "BigInt"
219+
"type": "BigInt",
232220
},
233221
{
234222
"name": "taxliabilities",
235223
"description": "Outstanding tax liabilities",
236-
"type": "BigInt"
224+
"type": "BigInt",
237225
},
238226
{
239227
"name": "cashnequsd",
240228
"description": "Cash and equivalents in USD",
241-
"type": "BigInt"
242-
}
229+
"type": "BigInt",
230+
},
243231
]
244232
return fields

0 commit comments

Comments
 (0)