gh-103668: Run pyugrade on idlelib (#103671)

---------
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
This commit is contained in:
Nikita Sobolev 2023-04-24 02:25:08 +03:00 committed by GitHub
parent 7255bbd4a1
commit bd2dca035a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 50 additions and 50 deletions

View file

@ -249,7 +249,7 @@ class PyShellEditorWindow(EditorWindow):
breaks = self.breakpoints
filename = self.io.filename
try:
with open(self.breakpointPath, "r") as fp:
with open(self.breakpointPath) as fp:
lines = fp.readlines()
except OSError:
lines = []
@ -279,7 +279,7 @@ class PyShellEditorWindow(EditorWindow):
if filename is None:
return
if os.path.isfile(self.breakpointPath):
with open(self.breakpointPath, "r") as fp:
with open(self.breakpointPath) as fp:
lines = fp.readlines()
for line in lines:
if line.startswith(filename + '='):
@ -441,7 +441,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
# run from the IDLE source directory.
del_exitf = idleConf.GetOption('main', 'General', 'delete-exitfunc',
default=False, type='bool')
command = "__import__('idlelib.run').run.main(%r)" % (del_exitf,)
command = f"__import__('idlelib.run').run.main({del_exitf!r})"
return [sys.executable] + w + ["-c", command, str(self.port)]
def start_subprocess(self):
@ -574,9 +574,9 @@ class ModifiedInterpreter(InteractiveInterpreter):
self.runcommand("""if 1:
import sys as _sys
_sys.path = %r
_sys.path = {!r}
del _sys
\n""" % (path,))
\n""".format(path))
active_seq = None
@ -703,14 +703,14 @@ class ModifiedInterpreter(InteractiveInterpreter):
def prepend_syspath(self, filename):
"Prepend sys.path with file's directory if not already included"
self.runcommand("""if 1:
_filename = %r
_filename = {!r}
import sys as _sys
from os.path import dirname as _dirname
_dir = _dirname(_filename)
if not _dir in _sys.path:
_sys.path.insert(0, _dir)
del _filename, _sys, _dirname, _dir
\n""" % (filename,))
\n""".format(filename))
def showsyntaxerror(self, filename=None):
"""Override Interactive Interpreter method: Use Colorizing
@ -1536,7 +1536,7 @@ def main():
try:
opts, args = getopt.getopt(sys.argv[1:], "c:deihnr:st:")
except getopt.error as msg:
print("Error: %s\n%s" % (msg, usage_msg), file=sys.stderr)
print(f"Error: {msg}\n{usage_msg}", file=sys.stderr)
sys.exit(2)
for o, a in opts:
if o == '-c':
@ -1668,9 +1668,9 @@ def main():
if cmd or script:
shell.interp.runcommand("""if 1:
import sys as _sys
_sys.argv = %r
_sys.argv = {!r}
del _sys
\n""" % (sys.argv,))
\n""".format(sys.argv))
if cmd:
shell.interp.execsource(cmd)
elif script: