Skip to content

Commit

Permalink
Fix pylint warnings in IV_Swinger2_gui.py (Issue #187)
Browse files Browse the repository at this point in the history
************* Module IV_Swinger2_gui
IV_Swinger2_gui.py:5017:0: R0022: Useless option value for 'disable', 'no-self-use' was moved to an optional extension, see https://pylint.pycqa.org/en/latest/whatsnew/2/2.14/summary.html#removed-checkers. (useless-option-value)
IV_Swinger2_gui.py:99:0: R0402: Use 'from tkinter import ttk' instead (consider-using-from-import)
IV_Swinger2_gui.py:281:15: R1732: Consider using 'with' for resource-allocating operations (consider-using-with)
IV_Swinger2_gui.py:353:12: W0621: Redefining name 'e' from outer scope (line 344) (redefined-outer-name)
IV_Swinger2_gui.py:732:12: R1732: Consider using 'with' for resource-allocating operations (consider-using-with)
IV_Swinger2_gui.py:1868:12: R1714: Consider merging these comparisons with 'in' by using 'event.widget in (self.img_size_combo, self.v_range_entry, self.i_range_entry)'. Use a set instead if elements are hashable. (consider-using-in)
  • Loading branch information
csatt committed Jan 21, 2023
1 parent 0245d69 commit 0948ba4
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions python3/IV_Swinger2_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@
import shutil
import sys
import tempfile
import tkinter.ttk as ttk
from tkinter import ttk
import tkinter as tk
import tkinter.filedialog as tkfiledialog
import tkinter.font as tkfont
import tkinter.messagebox as tkmsg
import traceback
from tkinter.scrolledtext import ScrolledText
from tkinter.constants import N, S, E, W, LEFT, RIGHT, HORIZONTAL, Y, BOTH, END
import traceback
from inspect import currentframe, getframeinfo
from configparser import NoOptionError
from send2trash import send2trash
Expand Down Expand Up @@ -278,18 +278,18 @@ def handle_early_exception():
if not getattr(sys, "frozen", False):
print(err_msg)
return
tmp_file = tempfile.NamedTemporaryFile(delete=False)
err_msg += "\n"
err_msg += """
with tempfile.NamedTemporaryFile(delete=False) as tmp_file:
err_msg += "\n"
err_msg += """
-----------------------------------------------------------
Please copy/paste the above and send it to csatt1@gmail.com
Alternately, you may attach this file:
{}
""".format(tmp_file.name)
with open(tmp_file.name, "a", encoding="utf-8") as f:
f.write(err_msg)
IV_Swinger2.sys_view_file(tmp_file.name)
with open(tmp_file.name, "a", encoding="utf-8") as f:
f.write(err_msg)
IV_Swinger2.sys_view_file(tmp_file.name)


def pdf_permission_denied(e):
Expand Down Expand Up @@ -350,13 +350,13 @@ def retry_if_pdf_permission_denied(func, *args):
tkmsg.showerror(message=err_str)
try:
rc = func(*args)
except IOError as e:
except IOError as ee:
rc = RC_FAILURE
if pdf_permission_denied(e):
if pdf_permission_denied(ee):
err_str = ("({})"
"\n\n"
"PDF still could not be written. "
"It will not be updated.".format(e))
"It will not be updated.".format(ee))
tkmsg.showerror(message=err_str)
return rc

Expand Down Expand Up @@ -729,7 +729,8 @@ def check_app_data_dir(self):
sys.exit()
try:
dummy_file = os.path.join(self.ivs2.app_data_dir, "DUMMY_FILE")
open(dummy_file, "a", encoding="utf-8").close()
with open(dummy_file, "a", encoding="utf-8") as f:
f.close()
os.remove(dummy_file)
except (IOError, OSError):
err_msg = """
Expand Down Expand Up @@ -1865,9 +1866,9 @@ def go_actions(self, event=None):
# This is necessary due to the "manual" bindings
return

if (event.widget == self.img_size_combo or
event.widget == self.v_range_entry or
event.widget == self.i_range_entry):
if (event.widget in (self.img_size_combo,
self.v_range_entry,
self.i_range_entry)):
# When Return key is hit in any of these widgets, it's to
# change their value, so bail out without doing anything
return
Expand Down Expand Up @@ -5014,7 +5015,7 @@ def snapshot(self):
# override

# -------------------------------------------------------------------------
def validate(self): # pylint: disable=no-self-use
def validate(self):
"""Method that checks values entered in the dialog for validity. Should
be overridden to do what is appropriate for the derived
class. Returns False if a check fails and True if all pass.
Expand Down

0 comments on commit 0948ba4

Please sign in to comment.