Skip to content

Commit b83b12a

Browse files
committed
feat: add configured pyrightconfig.json and remove type ignore annotations
1 parent 8969303 commit b83b12a

File tree

2 files changed

+39
-27
lines changed

2 files changed

+39
-27
lines changed

pyrightconfig.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"include": [
3+
"src"
4+
],
5+
"exclude": [
6+
"**/__pycache__",
7+
],
8+
"reportReturnType": false
9+
}

src/AppDPyAPI/controller.py

+30-27
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,15 @@ def _full_uri(self, endpoint: str) -> str:
153153
return f"{self.CONTROLLER_BASE_URL}{endpoint}"
154154

155155
@staticmethod
156-
def __request_or_raise(method: str,
157-
uri: str,
158-
object_name: str = "",
159-
json_decode: bool = True,
160-
single_element: bool = False,
161-
expected_status_code: int = 200,
162-
**kwargs: dict[str, str]):
156+
def __request_or_raise(
157+
method: str,
158+
uri: str,
159+
object_name: str = "",
160+
json_decode: bool = True,
161+
single_element: bool = False,
162+
expected_status_code: int = 200,
163+
**kwargs: dict[str, str]
164+
) -> Callable[[Callable[..., Any]], Callable[..., str | list[dict[str, str]] | dict[str, str]]]:
163165
"""Private method.
164166
165167
Uplink-style decorator for requests. Use like `_request_or_raise` but as decorator.
@@ -192,12 +194,13 @@ def get_application_decorated(application_name):
192194
outer_kwargs = kwargs
193195

194196
def _inner_request_or_raise_decorator(
195-
func: Callable[[Any], Any]) -> Callable[[Any], str | list[dict[str, str]]]:
197+
func: Callable[..., Any]) -> Callable[..., str | list[dict[str, str]] | dict[str, str]]:
196198
"""Handles function."""
197199

198200
@wraps(func)
199-
def __inner_request_or_raise_decorator(*args: list[Any],
200-
**kwargs: dict[str, str]) -> str | list[dict[str, str]]:
201+
def __inner_request_or_raise_decorator(
202+
*args: list[Any], **kwargs: dict[str,
203+
str]) -> str | list[dict[str, str]] | dict[str, str]:
201204
"""Handles arguments passed to function."""
202205
self: AppDController = args[0] # type: ignore
203206

@@ -229,7 +232,7 @@ def __inner_request_or_raise_decorator(*args: list[Any],
229232
return _inner_request_or_raise_decorator
230233

231234
@__request_or_raise("GET", "/controller/rest/applications", "applications")
232-
def get_applications(self) -> list[dict[str, str]]: # type: ignore
235+
def get_applications(self) -> list[dict[str, str]]:
233236
"""Request all applications from the controller, formatted in JSON.
234237
235238
Returns:
@@ -239,8 +242,8 @@ def get_applications(self) -> list[dict[str, str]]: # type: ignore
239242
@__request_or_raise("GET",
240243
"/controller/rest/applications/{application_name}",
241244
"application {application_name}",
242-
single_element=True) # type: ignore
243-
def get_application(self, application_name: str) -> dict[str, str]: # type: ignore
245+
single_element=True)
246+
def get_application(self, application_name: str) -> dict[str, str]:
244247
"""Request an application from the controller by application name, formatted in JSON.
245248
246249
Args:
@@ -251,8 +254,8 @@ def get_application(self, application_name: str) -> dict[str, str]: # type: ign
251254
"""
252255

253256
@__request_or_raise("GET", "/controller/rest/applications/{application_name}/business-transactions",
254-
"business transaction for {application_name}") # type: ignore
255-
def get_business_transactions(self, application_name: str) -> list[dict[str, str]]: # type: ignore
257+
"business transaction for {application_name}")
258+
def get_business_transactions(self, application_name: str) -> list[dict[str, str]]:
256259
"""Request all business transactions for an application by application name, formatted in JSON.
257260
258261
Args:
@@ -265,8 +268,8 @@ def get_business_transactions(self, application_name: str) -> list[dict[str, str
265268
@__request_or_raise("GET",
266269
"/controller/transactiondetection/{application_id}/custom",
267270
"custom detection rules for application with ID {application_id}",
268-
json_decode=False) # type: ignore
269-
def get_custom_transaction_detection_rules(self, application_id: int) -> str: # type: ignore
271+
json_decode=False)
272+
def get_custom_transaction_detection_rules(self, application_id: int) -> str:
270273
"""Request all custom transaction detection rules for an application by application ID,
271274
formatted in XML.
272275
@@ -280,8 +283,8 @@ def get_custom_transaction_detection_rules(self, application_id: int) -> str: #
280283
@__request_or_raise("GET",
281284
"/controller/transactiondetection/{application_id}/auto",
282285
"auto detection rules for application with ID {application_id}",
283-
json_decode=False) # type: ignore
284-
def get_auto_transaction_detection_rules(self, application_id: int) -> str: # type: ignore
286+
json_decode=False)
287+
def get_auto_transaction_detection_rules(self, application_id: int) -> str:
285288
"""Request all automatic transaction detection rules for an application by application ID,
286289
formatted in XML.
287290
@@ -305,7 +308,7 @@ def get_account_id(self) -> int:
305308
}).json()["id"])
306309

307310
@__request_or_raise("GET", "/controller/licensing/v1/account/{accountId}/allocation",
308-
"licensing allocations for account {accountId}") #type: ignore
311+
"licensing allocations for account {accountId}")
309312
def get_license_allocations(self, accountId: int):
310313
"""Requires Infrastructure-Based Licensing (IBL). Retrieve all license allocations for account with ID `accountId`.
311314
@@ -316,19 +319,19 @@ def get_license_allocations(self, accountId: int):
316319
list[dict[str, str | int | list[str]]]: The parsed API response.
317320
"""
318321

319-
@__request_or_raise(
320-
"GET", "/controller/licensing/v1/account/{accountId}/allocation?name={allocation_name}",
321-
"licensing allocations for account {accountId} for allocation {allocation_name}") #type: ignore
322+
@__request_or_raise("GET",
323+
"/controller/licensing/v1/account/{accountId}/allocation?name={allocation_name}",
324+
"licensing allocations for account {accountId} for allocation {allocation_name}")
322325
def get_license_allocation_by_name(self, accountId: int, allocation_name: str):
323326
"""Requires Infrastructure-Based Licensing (IBL). Like `get_license_allocations`, but additionally filtered by allocation name."""
324327

325-
@__request_or_raise(
326-
"GET", "/controller/licensing/v1/account/{accountId}/allocation?license-key={license_key}",
327-
"licensing allocations for account {accountId} for allocation {license_key}") #type: ignore
328+
@__request_or_raise("GET",
329+
"/controller/licensing/v1/account/{accountId}/allocation?license-key={license_key}",
330+
"licensing allocations for account {accountId} for allocation {license_key}")
328331
def get_license_allocation_by_license_key(self, accountId: int, license_key: str):
329332
"""Requires Infrastructure-Based Licensing (IBL). Like `get_license_allocations`, but additionally filtered by license key."""
330333

331334
@__request_or_raise("GET", "/controller/licensing/v1/account/{accountId}/allocation?tag={tag}",
332-
"licensing allocations for account {accountId} for allocation {tag}") #type: ignore
335+
"licensing allocations for account {accountId} for allocation {tag}")
333336
def get_license_allocations_by_tag(self, accountId: int, tag: str):
334337
"""Requires Infrastructure-Based Licensing (IBL). Like `get_license_allocations`, but additionally filtered by tag assocatied with allocations."""

0 commit comments

Comments
 (0)