diff --git a/TM1py/Services/CellService.py b/TM1py/Services/CellService.py index c4a2e40f..f4b54301 100644 --- a/TM1py/Services/CellService.py +++ b/TM1py/Services/CellService.py @@ -35,7 +35,7 @@ case_and_space_insensitive_equals, get_cube, resembles_mdx, require_admin, extract_compact_json_cellset, \ cell_is_updateable, build_mdx_from_cellset, build_mdx_and_values_from_cellset, \ dimension_names_from_element_unique_names, frame_to_significant_digits, build_dataframe_from_csv, \ - drop_dimension_properties + drop_dimension_properties, decohints try: import pandas as pd @@ -45,6 +45,7 @@ _has_pandas = False +@decohints def tidy_cellset(func): """ Higher order function to tidy up cellset after usage """ @@ -68,6 +69,7 @@ def wrapper(self, cellset_id, *args, **kwargs): return wrapper +@decohints def manage_transaction_log(func): """ Control state of transaction log during and after write operation for a given cube through: `deactivate_transaction_log` and `reactivate_transaction_log`. @@ -103,6 +105,7 @@ def wrapper(self, *args, **kwargs): return wrapper +@decohints def manage_changeset(func): """ Control the start and end of change sets which goups write events together in the TM1 transaction log. @@ -124,6 +127,7 @@ def wrapper(self, *args, **kwargs): return wrapper +@decohints def odata_compact_json(return_as_dict: bool): """ Higher order function to manage header and response when using compact JSON diff --git a/TM1py/Services/ChoreService.py b/TM1py/Services/ChoreService.py index 17a1e36e..d89d48af 100644 --- a/TM1py/Services/ChoreService.py +++ b/TM1py/Services/ChoreService.py @@ -10,9 +10,10 @@ from TM1py.Objects import Chore, ChoreTask from TM1py.Services.ObjectService import ObjectService from TM1py.Services.RestService import RestService -from TM1py.Utils import format_url +from TM1py.Utils import format_url, decohints +@decohints def deactivate_activate(func): """ Higher Order function to handle activation and deactivation of chores before updating them diff --git a/TM1py/Services/RestService.py b/TM1py/Services/RestService.py index c127807d..211f6379 100644 --- a/TM1py/Services/RestService.py +++ b/TM1py/Services/RestService.py @@ -18,7 +18,8 @@ # SSO not supported for Linux from TM1py.Exceptions.Exceptions import TM1pyTimeout -from TM1py.Utils import case_and_space_insensitive_equals, CaseAndSpaceInsensitiveSet, HTTPAdapterWithSocketOptions +from TM1py.Utils import case_and_space_insensitive_equals, CaseAndSpaceInsensitiveSet, HTTPAdapterWithSocketOptions, \ + decohints try: from requests_negotiate_sspi import HttpNegotiateAuth @@ -30,6 +31,7 @@ import http.client as http_client +@decohints def httpmethod(func): """ Higher Order Function to wrap the GET, POST, PATCH, PUT, DELETE methods Takes care of: diff --git a/TM1py/Services/ServerService.py b/TM1py/Services/ServerService.py index bda9ab7f..931dbc79 100644 --- a/TM1py/Services/ServerService.py +++ b/TM1py/Services/ServerService.py @@ -13,9 +13,11 @@ from TM1py.Services.ObjectService import ObjectService from TM1py.Services.RestService import RestService from TM1py.Utils import format_url -from TM1py.Utils.Utils import CaseAndSpaceInsensitiveDict, CaseAndSpaceInsensitiveSet, require_admin, require_version +from TM1py.Utils.Utils import CaseAndSpaceInsensitiveDict, CaseAndSpaceInsensitiveSet, require_admin, require_version, \ + decohints +@decohints def odata_track_changes_header(func): """ Higher Order function to handle addition and removal of odata.track-changes HTTP Header diff --git a/TM1py/Utils/Utils.py b/TM1py/Utils/Utils.py index bc3de75b..e32b4721 100644 --- a/TM1py/Utils/Utils.py +++ b/TM1py/Utils/Utils.py @@ -10,7 +10,7 @@ from contextlib import suppress from enum import Enum, unique from io import StringIO -from typing import Any, Dict, List, Tuple, Iterable, Optional, Generator, Union +from typing import Any, Dict, List, Tuple, Iterable, Optional, Generator, Union, Callable import requests from mdxpy import MdxBuilder, Member @@ -27,6 +27,16 @@ _has_pandas = False +def decohints(decorator: Callable) -> Callable: + """ + Decorator for decorators to see parameters of decorated functions in PyCharm + + Implementation of https://github.com/gri-gus/decohints + """ + return decorator + + +@decohints def require_admin(func): @functools.wraps(func) def wrapper(self, *args, **kwargs): @@ -37,6 +47,7 @@ def wrapper(self, *args, **kwargs): return wrapper +@decohints def require_version(version): """ Higher order function to check required version for TM1py function """ @@ -53,6 +64,7 @@ def wrapper(self, *args, **kwargs): return wrap +@decohints def require_pandas(func): @functools.wraps(func) def wrapper(self, *args, **kwargs):