Skip to content

Commit c87c458

Browse files
committed
chore: update pre-commit hooks and modernize type hints to Python 3.9+
1 parent 8ee9ffc commit c87c458

30 files changed

+156
-123
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@ repos:
33
rev: v3.1.0
44
hooks:
55
- id: pyupgrade
6-
args: [--py37-plus]
6+
args: [--py39-plus]
77
- repo: https://github.com/psf/black
88
rev: 22.10.0
99
hooks:
1010
- id: black
11-
- repo: https://github.com/myint/docformatter
12-
rev: v1.5.0
11+
- repo: https://github.com/PyCQA/docformatter
12+
rev: v1.7.7
1313
hooks:
1414
- id: docformatter
1515
args: [--in-place]
16+
language_version: python3
1617
- repo: https://github.com/PyCQA/flake8
1718
rev: 5.0.4
1819
hooks:

poetry.lock

Lines changed: 69 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

solnlib/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
1716
"""The Splunk Software Development Kit for Solutions."""
1817

1918
from . import (

solnlib/_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"""This module provide utils that are private to solnlib."""
1717

1818
import re
19-
from typing import Any, Dict, Optional, Union
19+
from typing import Any, Optional, Union
2020

2121
from splunklib import binding, client
2222

@@ -33,7 +33,7 @@ def get_collection_data(
3333
scheme: Optional[str] = None,
3434
host: Optional[str] = None,
3535
port: Optional[Union[str, int]] = None,
36-
fields: Optional[Dict] = None,
36+
fields: Optional[dict] = None,
3737
**context: Any,
3838
) -> client.KVStoreCollectionData:
3939
"""Get collection data, if there is no such collection - creates one.

solnlib/acl.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
1716
"""This module contains interfaces that support CRUD operations on ACL."""
1817

1918
import json
20-
from typing import List
2119

2220
from splunklib import binding
2321

@@ -108,8 +106,8 @@ def update(
108106
self,
109107
path: str,
110108
owner: str = None,
111-
perms_read: List = None,
112-
perms_write: List = None,
109+
perms_read: list = None,
110+
perms_write: list = None,
113111
) -> dict:
114112
"""Update ACL of /servicesNS/{`owner`}/{`app`}/{`path`}.
115113

solnlib/alerts_rest_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#
1616
import json
1717
from enum import Enum
18-
from typing import Tuple, Union, Optional
18+
from typing import Union, Optional
1919

2020
from solnlib import splunk_rest_client as rest_client
2121

@@ -89,7 +89,7 @@ def create_search_alert(
8989
alert_condition: str = "",
9090
alert_comparator: AlertComparator = AlertComparator.GREATER_THAN,
9191
alert_threshold: Union[int, float, str] = 0,
92-
time_window: Tuple[str, str] = ("-15m", "now"),
92+
time_window: tuple[str, str] = ("-15m", "now"),
9393
alert_severity: AlertSeverity = AlertSeverity.WARN,
9494
cron_schedule: str = "* * * * *",
9595
expires: Union[int, str] = "24h",
@@ -188,7 +188,7 @@ def update_search_alert(
188188
alert_condition: Optional[str] = None,
189189
alert_comparator: Optional[AlertComparator] = None,
190190
alert_threshold: Optional[Union[int, float, str]] = None,
191-
time_window: Optional[Tuple[str, str]] = None,
191+
time_window: Optional[tuple[str, str]] = None,
192192
alert_severity: Optional[AlertSeverity] = None,
193193
cron_schedule: Optional[str] = None,
194194
expires: Optional[Union[int, str]] = None,

solnlib/bulletin_rest_client.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#
1616

1717
from solnlib import splunk_rest_client as rest_client
18-
from typing import Optional, List
18+
from typing import Optional
1919
import json
2020

2121
__all__ = ["BulletinRestClient"]
@@ -40,18 +40,18 @@ def __init__(
4040
app: str,
4141
**context: dict,
4242
):
43-
"""Initializes BulletinRestClient.
44-
When creating a new bulletin message, you must provide a name, which is a kind of ID.
45-
If you try to create another message with the same name (ID), the API will not add another message
46-
to the bulletin, but it will overwrite the existing one. Similar behaviour applies to deletion.
47-
To delete a message, you must indicate the name (ID) of the message.
48-
To provide better and easier control over bulletin messages, this client works in such a way
49-
that there is one instance responsible for handling one specific message.
50-
If you need to add another message to bulletin create another instance
51-
with a different 'message_name'
52-
e.g.
53-
msg_1 = BulletinRestClient("message_1", "<some session key>")
54-
msg_2 = BulletinRestClient("message_2", "<some session key>")
43+
"""Initializes BulletinRestClient. When creating a new bulletin
44+
message, you must provide a name, which is a kind of ID. If you try to
45+
create another message with the same name (ID), the API will not add
46+
another message to the bulletin, but it will overwrite the existing
47+
one. Similar behaviour applies to deletion. To delete a message, you
48+
must indicate the name (ID) of the message. To provide better and
49+
easier control over bulletin messages, this client works in such a way
50+
that there is one instance responsible for handling one specific
51+
message. If you need to add another message to bulletin create another
52+
instance with a different 'message_name' e.g. msg_1 =
53+
BulletinRestClient("message_1", "<some session key>") msg_2 =
54+
BulletinRestClient("message_2", "<some session key>")
5555
5656
Arguments:
5757
message_name: Name of the message in the Splunk's bulletin.
@@ -72,8 +72,8 @@ def create_message(
7272
self,
7373
msg: str,
7474
severity: Severity = Severity.WARNING,
75-
capabilities: Optional[List[str]] = None,
76-
roles: Optional[List] = None,
75+
capabilities: Optional[list[str]] = None,
76+
roles: Optional[list] = None,
7777
):
7878
"""Creates a message in the Splunk's bulletin. Calling this method
7979
multiple times for the same instance will overwrite existing message.
@@ -144,7 +144,7 @@ def delete_message(self):
144144
self._rest_client.delete(endpoint)
145145

146146
@staticmethod
147-
def _validate_and_get_body_value(arg, error_msg) -> List:
147+
def _validate_and_get_body_value(arg, error_msg) -> list:
148148
if type(arg) is list and (all(isinstance(el, str) for el in arg)):
149149
return [el for el in arg]
150150
else:

solnlib/concurrent/concurrent_executor.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
1716
"""Concurrent executor provides concurrent executing function either in a
1817
thread pool or a process pool."""
1918

@@ -69,11 +68,11 @@ def run_io_func_async(self, func, args=(), kwargs=None, callback=None):
6968
return self._io_executor.apply_async(func, args, kwargs, callback)
7069

7170
def enqueue_io_funcs(self, funcs, block=True):
72-
"""run jobs in a fire and forget way, no result will be handled over to
71+
"""Run jobs in a fire and forget way, no result will be handled over to
7372
clients.
7473
75-
:param funcs: tuple/list-like or generator like object, func shall be
76-
callable
74+
:param funcs: tuple/list-like or generator like object, func
75+
shall be callable
7776
"""
7877

7978
return self._io_executor.enqueue_funcs(funcs, block)

solnlib/concurrent/process_pool.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
1716
"""A wrapper of multiprocessing.pool."""
1817

1918
import multiprocessing

solnlib/concurrent/thread_pool.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
1716
"""A simple thread pool implementation."""
1817

1918
import multiprocessing
@@ -94,11 +93,11 @@ def tear_down(self):
9493
logging.info("ThreadPool stopped.")
9594

9695
def enqueue_funcs(self, funcs, block=True):
97-
"""run jobs in a fire and forget way, no result will be handled over to
96+
"""Run jobs in a fire and forget way, no result will be handled over to
9897
clients.
9998
100-
:param funcs: tuple/list-like or generator like object, func shall be
101-
callable
99+
:param funcs: tuple/list-like or generator like object, func
100+
shall be callable
102101
"""
103102

104103
if not self._started:

0 commit comments

Comments
 (0)