Skip to content

Commit

Permalink
style: Fix new read-whole-file (FURB101) errors
Browse files Browse the repository at this point in the history
  • Loading branch information
echoix committed Jan 4, 2025
1 parent ccf4b7b commit d73fa47
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
6 changes: 3 additions & 3 deletions gui/wxpython/gmodeler/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import time

import xml.etree.ElementTree as ET
from pathlib import Path
from xml.sax import saxutils

import wx
Expand Down Expand Up @@ -542,9 +543,8 @@ def _substituteFile(self, item, params=None, checkOnly=False):

for finput in self.fileInput:
# read lines
with open(finput) as fd:
data = fd.read()
self.fileInput[finput] = data
data = Path(finput).read_text()
self.fileInput[finput] = data

# substitute variables
write = False
Expand Down
6 changes: 4 additions & 2 deletions gui/wxpython/gui_core/ghelp.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
import re
import textwrap
import sys

from pathlib import Path

import wx
from wx.html import HtmlWindow
from operator import itemgetter
Expand Down Expand Up @@ -274,8 +277,7 @@ def _pageCopyright(self):
"""Copyright information"""
copyfile = os.path.join(os.getenv("GISBASE"), "COPYING")
if os.path.exists(copyfile):
with open(copyfile) as copyrightFile:
copytext = copyrightFile.read()
copytext = Path(copyfile).read_text()
else:
copytext = _("%s file missing") % "COPYING"

Expand Down
4 changes: 1 addition & 3 deletions gui/wxpython/modules/colorrules.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,9 +694,7 @@ def OnLoadRulesFile(self, event):
return

self.rulesPanel.Clear()

with open(path) as fd:
self.ReadColorTable(ctable=fd.read())
self.ReadColorTable(ctable=Path(path).read_text())

def ReadColorTable(self, ctable):
"""Read color table
Expand Down
3 changes: 1 addition & 2 deletions gui/wxpython/modules/mcalc_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,8 +752,7 @@ def OnLoadExpression(self, event):
dlg.Destroy()
return

with open(path) as fobj:
mctxt = fobj.read()
mctxt = Path(path).read_text()

try:
result, exp = mctxt.split("=", 1)
Expand Down

0 comments on commit d73fa47

Please sign in to comment.