Skip to content

Commit 5acb649

Browse files
authored
style: add pyupgrade and isort to pre-commit (#552)
* style: pre-commit update * style: apply pyupgrade * style: apply isort
1 parent eb940bc commit 5acb649

File tree

112 files changed

+571
-498
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+571
-498
lines changed

.pre-commit-config.yaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,17 @@ repos:
1919
hooks:
2020
- id: check-merge-conflict
2121
- id: debug-statements
22+
- repo: https://github.com/asottile/pyupgrade
23+
rev: v2.31.0
24+
hooks:
25+
- id: pyupgrade
26+
args:
27+
- --py37-plus
2228
- repo: https://github.com/psf/black
23-
rev: 21.12b0
29+
rev: 22.1.0
2430
hooks:
2531
- id: black
32+
- repo: https://github.com/PyCQA/isort
33+
rev: 5.10.1
34+
hooks:
35+
- id: isort

docs/conf.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
#
32
# Configuration file for the Sphinx documentation builder.
43
#
@@ -14,21 +13,22 @@
1413
#
1514
import os
1615
import sys
16+
1717
import sphinx_rtd_theme
1818

1919
sys.path.insert(0, os.path.abspath("../pytest_splunk_addon"))
2020

2121

2222
# -- Project information -----------------------------------------------------
2323

24-
project = u"pytest-splunk-addon"
25-
copyright = u"2021, Splunk, Inc."
26-
author = u"Splunk, Inc."
24+
project = "pytest-splunk-addon"
25+
copyright = "2021, Splunk, Inc."
26+
author = "Splunk, Inc."
2727

2828
# The short X.Y version
29-
version = u""
29+
version = ""
3030
# The full version, including alpha/beta/rc tags
31-
release = u""
31+
release = ""
3232

3333

3434
# -- General configuration ---------------------------------------------------
@@ -134,8 +134,8 @@
134134
(
135135
master_doc,
136136
"pytest-splunk-addon.tex",
137-
u"pytest-splunk-addon Documentation",
138-
u"Splunk, Inc.",
137+
"pytest-splunk-addon Documentation",
138+
"Splunk, Inc.",
139139
"manual",
140140
),
141141
]
@@ -149,7 +149,7 @@
149149
(
150150
master_doc,
151151
"pytest-splunk-addon",
152-
u"pytest-splunk-addon Documentation",
152+
"pytest-splunk-addon Documentation",
153153
[author],
154154
1,
155155
)
@@ -165,7 +165,7 @@
165165
(
166166
master_doc,
167167
"pytest-splunk-addon",
168-
u"pytest-splunk-addon Documentation",
168+
"pytest-splunk-addon Documentation",
169169
author,
170170
"pytest-splunk-addon",
171171
"One line description of project.",

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ pytz = "^2021.1"
5959
sphinx-rtd-theme = "^1.0.0"
6060
sphinx-panels = "^0.6.0"
6161

62+
[tool.isort]
63+
profile = "black"
64+
6265
[tool.poetry.plugins]
6366
pytest11 = { plugin = "pytest_splunk_addon.plugin", "splunk" = "pytest_splunk_addon.splunk" }
6467

pytest_splunk_addon/helmut/connector/sdk.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
import logging
1717
import time
1818

19-
from splunklib.binding import _NoAuthenticationToken, AuthenticationError
20-
from splunklib.client import Service, Endpoint
19+
from splunklib.binding import AuthenticationError, _NoAuthenticationToken
20+
from splunklib.client import Endpoint, Service
2121

2222
LOGGER = logging.getLogger("helmut")
2323

@@ -265,13 +265,11 @@ def is_logged_in(self):
265265
# FAST-8222
266266
except AuthenticationError as err:
267267
LOGGER.debug(
268-
"SDKconnector %s:%s is NOT logged in" % (self.username, self.password)
268+
f"SDKconnector {self.username}:{self.password} is NOT logged in"
269269
)
270270
return False
271271
else:
272-
LOGGER.debug(
273-
"SDKconnector %s:%s is logged in" % (self.username, self.password)
274-
)
272+
LOGGER.debug(f"SDKconnector {self.username}:{self.password} is logged in")
275273
return True
276274

277275
def _was_logged_in(self):

pytest_splunk_addon/helmut/exceptions/job.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
class JobNotFound(RuntimeError):
1717
def __init__(self, sid):
1818
self.sid = sid
19-
super(JobNotFound, self).__init__(self._error_message)
19+
super().__init__(self._error_message)
2020

2121
@property
2222
def _error_message(self):
23-
return "Could not find a job with SID {sid}".format(sid=self.sid)
23+
return f"Could not find a job with SID {self.sid}"

pytest_splunk_addon/helmut/exceptions/search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class SearchFailure(RuntimeError):
2020

2121
def __init__(self, search_message):
2222
self.search_message = search_message
23-
super(SearchFailure, self).__init__(self._error_message)
23+
super().__init__(self._error_message)
2424

2525
@property
2626
def _error_message(self):

pytest_splunk_addon/helmut/exceptions/wait.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class WaitTimedOut(RuntimeError):
2020

2121
def __init__(self, seconds_waited):
2222
self.seconds_waited = seconds_waited
23-
super(WaitTimedOut, self).__init__(self._error_message)
23+
super().__init__(self._error_message)
2424

2525
@property
2626
def _error_message(self):

pytest_splunk_addon/helmut/manager/jobs/results.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import copy
1717

1818

19-
class Results(object):
19+
class Results:
2020
"""
2121
A class that represents a result set.
2222
@@ -61,7 +61,7 @@ def __init__(self, results_):
6161
@param results_: The raw results as returned by ResultReader
6262
@type results_: list
6363
"""
64-
super(Results, self).__init__()
64+
super().__init__()
6565

6666
self._list = results_
6767
self._dict_cache = None
@@ -73,7 +73,7 @@ def __repr__(self):
7373
@return: The representation
7474
@rtype: str
7575
"""
76-
return "Results set with {count} result(s)".format(count=len(self))
76+
return f"Results set with {len(self)} result(s)"
7777

7878
def get_field(self, field):
7979
"""

pytest_splunk_addon/helmut/manager/jobs/sdk/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ def __len__(self):
4141
return len(list(self.items()))
4242

4343
def __iter__(self):
44-
for item in list(self.items()):
45-
yield item
44+
yield from list(self.items())
4645

4746
def __contains__(self, sid):
4847
for job in self:

pytest_splunk_addon/helmut/manager/jobs/sdk/job.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818

1919
import splunklib.results as results
2020

21-
from pytest_splunk_addon.helmut.manager.jobs.results import Results
2221
from pytest_splunk_addon.helmut.exceptions.search import SearchFailure
2322
from pytest_splunk_addon.helmut.exceptions.wait import WaitTimedOut
23+
from pytest_splunk_addon.helmut.manager.jobs.results import Results
2424

2525
LOGGER = logging.getLogger("helmut")
2626

@@ -49,7 +49,7 @@ def sid(self):
4949
return self.raw_sdk_job.sid
5050

5151
def __str__(self):
52-
return "SDK Job with SID {sid}".format(sid=self.sid)
52+
return f"SDK Job with SID {self.sid}"
5353

5454
def get_event_count(self):
5555
return int(self.raw_sdk_job.refresh().content.eventCount)

0 commit comments

Comments
 (0)