Skip to content

Commit 91e3476

Browse files
committed
Increase max line width to 180
1 parent 8f0e34b commit 91e3476

File tree

7 files changed

+22
-71
lines changed

7 files changed

+22
-71
lines changed

ircurltitlebot/__main__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ def load_config() -> None:
2828
if "sites" in logged_instance_config:
2929
del logged_instance_config["sites"]
3030
log.info(
31-
"Read user configuration file %s having excerpted configuration: %s",
32-
instance_config_path,
33-
logged_instance_config,
31+
"Read user configuration file %s having excerpted configuration: %s", instance_config_path, logged_instance_config,
3432
)
3533
for site, site_config in instance_config.get("sites", {}).items():
3634
log.info("User configuration for site %s is: %s", site, site_config)

ircurltitlebot/bot.py

Lines changed: 14 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ class Bot:
3636

3737
def __init__(self) -> None:
3838
log.info(
39-
"Initializing bot as: %s",
40-
subprocess.check_output("id", text=True).rstrip(), # pylint: disable=unexpected-keyword-arg
39+
"Initializing bot as: %s", subprocess.check_output("id", text=True).rstrip(), # pylint: disable=unexpected-keyword-arg
4140
)
4241
instance = config.INSTANCE
4342
self._setup_channel_queues() # Sets up executors and queues required by IRC handler.
@@ -83,19 +82,14 @@ def _msg_channel(self, channel: str) -> NoReturn: # pylint: disable=too-many-lo
8382
user, url, title = result
8483
if title.casefold() in title_blacklist:
8584
log.info(
86-
"Skipping globally blacklisted title %s for %s in %s for URL %s",
87-
repr(title),
88-
user,
89-
channel,
90-
url,
85+
"Skipping globally blacklisted title %s for %s in %s for URL %s", repr(title), user, channel, url,
9186
)
9287
continue
9388
msg = f"{title_prefix} {title}"
9489
if irc.connected:
9590
irc.msg(channel, msg)
9691
log.info(
97-
"Sent outgoing message for %s in %s in %.1fs having content %s for URL %s with %s "
98-
"active threads.",
92+
"Sent outgoing message for %s in %s in %.1fs having content %s for URL %s with %s " "active threads.",
9993
user,
10094
channel,
10195
time.monotonic() - start_time,
@@ -105,8 +99,7 @@ def _msg_channel(self, channel: str) -> NoReturn: # pylint: disable=too-many-lo
10599
)
106100
else:
107101
log.warning(
108-
"Skipped outgoing message for %s in %s in %.1fs having content %s for URL %s with %s "
109-
"active threads because the IRC client is not connected.",
102+
"Skipped outgoing message for %s in %s in %.1fs having content %s for URL %s with %s " "active threads because the IRC client is not connected.",
110103
user,
111104
channel,
112105
time.monotonic() - start_time,
@@ -120,46 +113,30 @@ def _setup_channel_queues(self) -> None:
120113
channels_str = ", ".join(channels)
121114
active_count = threading.active_count
122115
log.debug(
123-
"Setting up executor and queue for %s channels (%s) with %s currently active threads.",
124-
len(channels),
125-
channels_str,
126-
active_count(),
116+
"Setting up executor and queue for %s channels (%s) with %s currently active threads.", len(channels), channels_str, active_count(),
127117
)
128118
for channel in channels:
129119
log.debug("Setting up executor and queue for %s.", channel)
130-
self.EXECUTORS[channel] = concurrent.futures.ThreadPoolExecutor(
131-
max_workers=config.MAX_WORKERS_PER_CHANNEL, thread_name_prefix=f"TitleReader-{channel}"
132-
)
120+
self.EXECUTORS[channel] = concurrent.futures.ThreadPoolExecutor(max_workers=config.MAX_WORKERS_PER_CHANNEL, thread_name_prefix=f"TitleReader-{channel}")
133121
self.QUEUES[channel] = queue.SimpleQueue()
134122
log.debug(
135-
"Finished setting up executor and queue for %s with %s currently active threads.",
136-
channel,
137-
active_count(),
123+
"Finished setting up executor and queue for %s with %s currently active threads.", channel, active_count(),
138124
)
139125
log.info(
140-
"Finished setting up executor and queue for %s channels (%s) with %s currently active threads.",
141-
len(channels),
142-
channels_str,
143-
active_count(),
126+
"Finished setting up executor and queue for %s channels (%s) with %s currently active threads.", len(channels), channels_str, active_count(),
144127
)
145128

146129
def _setup_channel_threads(self) -> None:
147130
channels = config.INSTANCE["channels"]
148131
channels_str = ", ".join(channels)
149132
active_count = threading.active_count
150133
log.debug(
151-
"Setting up thread for %s channels (%s) with %s currently active threads.",
152-
len(channels),
153-
channels_str,
154-
active_count(),
134+
"Setting up thread for %s channels (%s) with %s currently active threads.", len(channels), channels_str, active_count(),
155135
)
156136
for channel in channels:
157137
threading.Thread(target=self._msg_channel, name=f"ChannelMessenger-{channel}", args=(channel,)).start()
158138
log.info(
159-
"Finished setting up thread for %s channels (%s) with %s currently active threads.",
160-
len(channels),
161-
channels_str,
162-
active_count(),
139+
"Finished setting up thread for %s channels (%s) with %s currently active threads.", len(channels), channels_str, active_count(),
163140
)
164141

165142

@@ -173,10 +150,7 @@ def _get_title(irc: miniirc.IRC, channel: str, user: str, url: str) -> Optional[
173150
# Note: exc almost always includes the actual URL, so it need not be duplicated in the alert.
174151
if url.endswith(PUNCTUATION):
175152
period = "" if msg.endswith(".") else "."
176-
msg += (
177-
f'{period} It will however be reattempted with its trailing punctuation character "{url[-1]}" '
178-
"stripped."
179-
)
153+
msg += f'{period} It will however be reattempted with its trailing punctuation character "{url[-1]}" ' "stripped."
180154
log.info(msg)
181155
else:
182156
_alert(irc, msg)
@@ -185,12 +159,7 @@ def _get_title(irc: miniirc.IRC, channel: str, user: str, url: str) -> Optional[
185159
else:
186160
if title: # Filter out None or blank title.
187161
log.debug(
188-
'Returning title "%s" for URL %s in message from %s in %s in %.1fs.',
189-
title,
190-
url,
191-
user,
192-
channel,
193-
time.monotonic() - start_time,
162+
'Returning title "%s" for URL %s in message from %s in %s in %.1fs.', title, url, user, channel, time.monotonic() - start_time,
194163
)
195164
return user, url, title
196165
return None
@@ -210,10 +179,7 @@ def _handle_900_loggedin(irc: miniirc.IRC, hostmask: Tuple[str, str, str], args:
210179
log.info("The client identity as <nick>!<user>@<host> is %s.", identity)
211180
if nick_casefold != config.INSTANCE["nick:casefold"]:
212181
_alert(
213-
irc,
214-
f"The client nick was configured to be {config.INSTANCE['nick']} but it is {nick}. "
215-
"The configured nick will be regained.",
216-
logging.WARNING,
182+
irc, f"The client nick was configured to be {config.INSTANCE['nick']} but it is {nick}. The configured nick will be regained.", logging.WARNING,
217183
)
218184
irc.msg("nickserv", "REGAIN", config.INSTANCE["nick"], os.environ["IRC_PASSWORD"])
219185

@@ -252,9 +218,7 @@ def _handle_privmsg(irc: miniirc.IRC, hostmask: Tuple[str, str, str], args: List
252218
# Ignoring private message from freenode-connect having ident frigg
253219
# and hostname freenode/utility-bot/frigg: VERSION
254220
_alert(
255-
irc,
256-
f"Ignoring private message from {user} having ident {ident} and hostname {hostname}: {msg}",
257-
logging.WARNING,
221+
irc, f"Ignoring private message from {user} having ident {ident} and hostname {hostname}: {msg}", logging.WARNING,
258222
)
259223
return
260224

ircurltitlebot/config.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,9 @@ def configure_logging() -> None:
2626
LOGGING = { # Ref: https://docs.python.org/3/howto/logging.html#configuring-logging
2727
"version": 1,
2828
"formatters": {
29-
"detailed": {
30-
"format": "%(asctime)s %(levelname)s %(threadName)s:%(name)s:%(lineno)d:%(funcName)s: %(message)s",
31-
}, # Note: Use %(thread)x- if needed for thread ID.
32-
},
33-
"handlers": {
34-
"console": {
35-
"class": "logging.StreamHandler",
36-
"level": "DEBUG",
37-
"formatter": "detailed",
38-
"stream": "ext://sys.stdout",
39-
},
29+
"detailed": {"format": "%(asctime)s %(levelname)s %(threadName)s:%(name)s:%(lineno)d:%(funcName)s: %(message)s",}, # Note: Use %(thread)x- if needed for thread ID.
4030
},
31+
"handlers": {"console": {"class": "logging.StreamHandler", "level": "DEBUG", "formatter": "detailed", "stream": "ext://sys.stdout",},},
4132
"loggers": {
4233
PACKAGE_NAME: {"level": "INFO", "handlers": ["console"], "propagate": False},
4334
"urltitle": {"level": "INFO", "handlers": ["console"], "propagate": False},

ircurltitlebot/title.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ def title(self, url: str, channel: str) -> Optional[str]:
3030

3131
# Skip blacklisted title
3232
blacklist = site_config.get("blacklist", {})
33-
if title == blacklist.get("title") or (
34-
(bl_re := blacklist.get("title_re")) and re.search(bl_re, title) # pylint: disable=used-before-assignment
35-
):
33+
if title == blacklist.get("title") or ((bl_re := blacklist.get("title_re")) and re.search(bl_re, title)): # pylint: disable=used-before-assignment
3634
log.info("Skipping blacklisted title %s for site %s.", repr(title), site)
3735
return None
3836

pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ disable=
2323
output-format=colorized
2424

2525
[FORMAT]
26-
max-line-length=120
26+
max-line-length=180

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tool.black]
2-
line-length = 120
2+
line-length = 180
33

44
[tool.isort]
5-
line_Length = 120
5+
line_Length = 180

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ warn_redundant_casts = True
1414
ignore = E203,E231,E501,E701,E731,W503
1515
# Ref: http://pycodestyle.pycqa.org/en/stable/intro.html#error-codes
1616
# Note: These ignores are to make autopep8==1.4.4 work with Python 3.8 assignment expressions: E203,E231,E701
17-
max-line-length = 120
17+
max-line-length = 180
1818

1919
[pydocstyle]
2020
ignore = D100,D101,D102,D103,D104,D105,D106,D107,D203,D213

0 commit comments

Comments
 (0)