Skip to content

Commit

Permalink
Fix pylint W1201 and W1202
Browse files Browse the repository at this point in the history
Fixing pylint warnings:
W1201: Use lazy % formatting in logging functions (logging-not-lazy)
W1202: Use lazy % or % formatting in logging functions (logging-format-interpolation)

Signed-off-by: Sandro Bonazzola <[email protected]>
  • Loading branch information
sandrobonazzola committed Jan 16, 2025
1 parent bb23ea5 commit 5847e09
Show file tree
Hide file tree
Showing 24 changed files with 164 additions and 172 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
Expand Down
3 changes: 3 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[MESSAGES]
disable=all
enable=W1201,W1202
6 changes: 3 additions & 3 deletions did/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def __init__(self, config=None, path=None):
path = Config.path()
# Parse the config from file
try:
log.info("Inspecting config file '{0}'.".format(path))
log.info("Inspecting config file '%s'.", path)
self.parser.read_file(codecs.open(path, "r", "utf8"))
except IOError as error:
log.debug(error)
Expand Down Expand Up @@ -497,12 +497,12 @@ def alias(self, aliases, stats):
# Update login/email if alias detected
if email is not None:
self.email = email
log.info("Using email alias '{0}' for '{1}'".format(email, stats))
log.info("Using email alias '%s' for '%s'", email, stats)
if login is None:
login = email.split("@")[0]
if login is not None:
self.login = login
log.info("Using login alias '{0}' for '{1}'".format(login, stats))
log.info("Using login alias '%s' for '%s'", login, stats)


def get_token(
Expand Down
6 changes: 3 additions & 3 deletions did/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def __init__(self, arguments=None):
log.debug("Loading Sample Stats group to build Options")
self.sample_stats = UserStats()
self.sample_stats.add_option(self.parser)
log.info("Default command line: did {0}".format(" ".join(
[f'--{stat.option}' for stat in self.sample_stats.stats])))
log.info("Default command line: did %s",
(" ".join([f'--{stat.option}' for stat in self.sample_stats.stats])))

# Formating options
group = self.parser.add_argument_group("Format")
Expand Down Expand Up @@ -161,7 +161,7 @@ def parse(self):

# Finito
log.debug("Gathered options:")
log.debug('options = {0}'.format(opt))
log.debug('options = %s', opt)
return opt, header

def check(self):
Expand Down
7 changes: 3 additions & 4 deletions did/plugins/bodhi.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@ def search(self, query):
current_page = 1
original_query = query
while current_page:
log.debug("Bodhi query: {0}".format(query))
log.debug("Bodhi query: %s", query)
client = BodhiClient(self.url)
data = client.send_request(query, verb='GET')
objects = data['updates']
log.debug("Result: {0} fetched".format(
listed(len(objects), "item")))
log.debug("Result: %s fetched", listed(len(objects), "item"))
log.data(pretty(data))
result.extend(objects)
if current_page < data['pages']:
Expand Down Expand Up @@ -82,7 +81,7 @@ class UpdatesCreated(Stats):
""" Updates created """

def fetch(self):
log.info('Searching for updates created by {0}'.format(self.user))
log.info('Searching for updates created by %s', self.user)
self.stats = [
Update(update, self.parent.options.format)
for update in self.parent.bodhi.search(
Expand Down
18 changes: 9 additions & 9 deletions did/plugins/bugzilla.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ class VerifiedBugs(Stats):
"""

def fetch(self):
log.info("Searching for bugs verified by {0}".format(self.user))
log.info("Searching for bugs verified by %s", self.user)
# Common query options
query = {
# Status changed to VERIFIED
Expand Down Expand Up @@ -337,7 +337,7 @@ class ReturnedBugs(Stats):
"""

def fetch(self):
log.info("Searching for bugs returned by {0}".format(self.user))
log.info("Searching for bugs returned by %s", self.user)
query = {
# User is not the assignee
"f1": "assigned_to",
Expand Down Expand Up @@ -374,7 +374,7 @@ class FiledBugs(Stats):
"""

def fetch(self):
log.info("Searching for bugs filed by {0}".format(self.user))
log.info("Searching for bugs filed by %s", self.user)
query = {
# User is the reporter
"f1": "reporter",
Expand Down Expand Up @@ -402,7 +402,7 @@ class FixedBugs(Stats):
"""

def fetch(self):
log.info("Searching for bugs fixed by {0}".format(self.user))
log.info("Searching for bugs fixed by %s", self.user)
query = {
# User is the assignee
"f1": "assigned_to",
Expand Down Expand Up @@ -438,7 +438,7 @@ class ClosedBugs(Stats):
"""

def fetch(self):
log.info("Searching for bugs closed by {0}".format(self.user))
log.info("Searching for bugs closed by %s", self.user)
query = {
# Status changed by the user
"f1": "bug_status",
Expand Down Expand Up @@ -476,7 +476,7 @@ class PostedBugs(Stats):
"""

def fetch(self):
log.info("Searching for bugs posted by {0}".format(self.user))
log.info("Searching for bugs posted by %s", self.user)
query = {
# User is the assignee
"f1": "assigned_to",
Expand Down Expand Up @@ -511,7 +511,7 @@ class PatchedBugs(Stats):
"""

def fetch(self):
log.info("Searching for bugs patched by {0}".format(self.user))
log.info("Searching for bugs patched by %s", self.user)
query = {
# Keywords field changed by the user
"f1": "keywords",
Expand Down Expand Up @@ -576,7 +576,7 @@ class CommentedBugs(Stats):
"""

def fetch(self):
log.info("Searching for bugs commented by {0}".format(self.user))
log.info("Searching for bugs commented by %s", self.user)
query = {
# Commented by the user
"f1": "longdesc",
Expand Down Expand Up @@ -605,7 +605,7 @@ class SubscribedBugs(Stats):
"""

def fetch(self):
log.info("Searching for bugs subscribed by {0}".format(self.user))
log.info("Searching for bugs subscribed by %s", self.user)
query = {
# Subscribed by the user
"f1": "cc",
Expand Down
15 changes: 9 additions & 6 deletions did/plugins/confluence.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class Confluence(object):
@staticmethod
def search(query, stats, expand=None):
""" Perform page/comment search for given stats instance """
log.debug("Search query: {0}".format(query))
log.debug("Search query: %s", query)
content = []

# Fetch data from the server in batches of MAX_RESULTS issues
Expand All @@ -81,8 +81,11 @@ def search(query, stats, expand=None):
"start": batch * MAX_RESULTS})))
data = response.json()
log.debug(
"Batch {0} result: {1} fetched".format(
batch, listed(data["results"], "object")))
"Batch %s result: %s fetched",
batch,
listed(
data["results"],
"object"))
log.data(pretty(data))
content.extend(data["results"])
# If all issues fetched, we're done
Expand Down Expand Up @@ -129,7 +132,7 @@ class PageCreated(Stats):
""" Created pages """

def fetch(self):
log.info("Searching for pages created by {0}".format(self.user))
log.info("Searching for pages created by %s", self.user)
query = (
"type=page AND creator = '{0}' "
"AND created >= {1} AND created < {2}".format(
Expand All @@ -140,7 +143,7 @@ def fetch(self):

class CommentAdded(Stats):
def fetch(self):
log.info("Searching for comments added by {0}".format(self.user))
log.info("Searching for comments added by %s", self.user)
query = (
"type=comment AND creator = '{0}' "
"AND created >= {1} AND created < {2}".format(
Expand Down Expand Up @@ -241,7 +244,7 @@ def session(self):
""" Initialize the session """
if self._session is None:
self._session = requests.Session()
log.debug("Connecting to {0}".format(self.auth_url))
log.debug("Connecting to %s", self.auth_url)
# Disable SSL warning when ssl_verify is False
if not self.ssl_verify:
requests.packages.urllib3.disable_warnings(
Expand Down
Loading

0 comments on commit 5847e09

Please sign in to comment.