Skip to content

Commit 5cc2c3f

Browse files
committed
Avoid string formatting if not producing any log output
1 parent cc9cbbf commit 5cc2c3f

File tree

3 files changed

+15
-23
lines changed

3 files changed

+15
-23
lines changed

bpython/args.py

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -204,24 +204,17 @@ def callback(group):
204204
bpython_logger.addHandler(logging.NullHandler())
205205
curtsies_logger.addHandler(logging.NullHandler())
206206

207-
logger.info(f"Starting bpython {__version__}")
208-
logger.info(f"Python {sys.executable}: {sys.version_info}")
209-
logger.info(f"curtsies: {curtsies.__version__}")
210-
logger.info(f"cwcwidth: {cwcwidth.__version__}")
211-
logger.info(f"greenlet: {greenlet.__version__}")
212-
logger.info(f"pygments: {pygments.__version__}") # type: ignore
213-
logger.info(f"requests: {requests.__version__}")
214-
logger.info(
215-
"environment:\n{}".format(
216-
"\n".join(
217-
f"{key}: {value}"
218-
for key, value in sorted(os.environ.items())
219-
if key.startswith("LC")
220-
or key.startswith("LANG")
221-
or key == "TERM"
222-
)
223-
)
224-
)
207+
logger.info("Starting bpython %s", __version__)
208+
logger.info("Python %s: %s", sys.executable, sys.version_info)
209+
logger.info("curtsies: %s", curtsies.__version__)
210+
logger.info("cwcwidth: %s", cwcwidth.__version__)
211+
logger.info("greenlet: %s", greenlet.__version__)
212+
logger.info("pygments: %s", pygments.__version__) # type: ignore
213+
logger.info("requests: %s", requests.__version__)
214+
logger.info("environment:")
215+
for key, value in sorted(os.environ.items()):
216+
if key.startswith("LC") or key.startswith("LANG") or key == "TERM":
217+
logger.info("%s: %s", key, value)
225218

226219
return Config(options.config), options, options.args
227220

bpython/autocomplete.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555
from .importcompletion import ModuleGatherer
5656

5757

58+
logger = logging.getLogger(__name__)
59+
5860
# Autocomplete modes
5961
class AutocompleteModes(Enum):
6062
NONE = "none"
@@ -767,11 +769,8 @@ def get_completer(
767769
)
768770
except Exception as e:
769771
# Instead of crashing the UI, log exceptions from autocompleters.
770-
logger = logging.getLogger(__name__)
771772
logger.debug(
772-
"Completer {} failed with unhandled exception: {}".format(
773-
completer, e
774-
)
773+
"Completer %r failed with unhandled exception: %s", completer, e
775774
)
776775
continue
777776
if matches is not None:

bpython/curtsiesfrontend/repl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,7 @@ def only_whitespace_left_of_cursor():
10051005
"""returns true if all characters before cursor are whitespace"""
10061006
return not self.current_line[: self.cursor_offset].strip()
10071007

1008-
logger.debug("self.matches_iter.matches:%r", self.matches_iter.matches)
1008+
logger.debug("self.matches_iter.matches: %r", self.matches_iter.matches)
10091009
if only_whitespace_left_of_cursor():
10101010
front_ws = len(self.current_line[: self.cursor_offset]) - len(
10111011
self.current_line[: self.cursor_offset].lstrip()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy