Fix refurb FURB110 suggestion (Issue #215)
by Chris Satterlee 1 year 11 months
Fix refurb FURB110 suggestion (Issue #215)

Fixed this one:

csatt@Chriss-2021-MBP_209.16:43:06[GitHub/IV_Swinger/python3]=> refurb --disable-all --enable FURB110 *.py
IV_Swinger2_gui.py:506:29 [FURB110]: Replace `x if x else y` with `x or y`
1ecf56f2
Fix refurb FURB107 suggestions (Issue #215)
by Chris Satterlee 1 year 11 months
Fix refurb FURB107 suggestions (Issue #215)

Fixed these:
csatt@Chriss-2021-MBP_209.16:21:03[GitHub/IV_Swinger/python3]=> refurb --disable-all --enable FURB107 *.py
IV_Swinger2_gui.py:90:1 [FURB107]: Replace `try: ... except ImportError: pass` with `with suppress(ImportError): ...`
IV_Swinger2_gui.py:1658:9 [FURB107]: Replace `try: ... except ValueError: pass` with `with suppress(ValueError): ...`
IV_Swinger2_gui.py:4330:9 [FURB107]: Replace `try: ... except IndexError: pass` with `with suppress(IndexError): ...`
IV_Swinger2_gui.py:9578:9 [FURB107]: Replace `try: ... except: pass` with `with suppress(BaseException): ...`
7f24a7da
Fix refurb FURB145 suggestions (Issue #215)
by Chris Satterlee 1 year 11 months
Fix refurb FURB145 suggestions (Issue #215)

Fixed these:

csatt@Chriss-2021-MBP_209.16:17:50[GitHub/IV_Swinger/python3]=> refurb --disable-all --enable FURB145 *.py
IV_Swinger2.py:501:20 [FURB145]: Replace `x[:]` with `x.copy()`
IV_Swinger2.py:4404:35 [FURB145]: Replace `x[:]` with `x.copy()`
IV_Swinger2.py:4469:35 [FURB145]: Replace `x[:]` with `x.copy()`
cf8ec36e
Fix refurb FURB109 suggestions (Issue #215)
by Chris Satterlee 1 year 11 months
Fix refurb FURB109 suggestions (Issue #215)

Fixed these as recommended:

csatt@Chriss-2021-MBP_209.16:09:52[GitHub/IV_Swinger/python3]=> refurb --disable-all --enable FURB109 *.py
IV_Swinger2.py:394:27 [FURB109]: Replace `in [x, y, z]` with `in (x, y, z)`
IV_Swinger2_gui.py:809:48 [FURB109]: Replace `not in [x, y, z]` with `not in (x, y, z)`
IV_Swinger_PV_model.py:539:23 [FURB109]: Replace `in [x, y, z]` with `in (x, y, z)`
IV_Swinger_PV_model.py:540:24 [FURB109]: Replace `in [x, y, z]` with `in (x, y, z)`
IV_Swinger_PV_model.py:672:18 [FURB109]: Replace `in [x, y, z]` with `in (x, y, z)`
IV_Swinger_PV_model.py:686:18 [FURB109]: Replace `in [x, y, z]` with `in (x, y, z)`
IV_Swinger_PV_model.py:699:18 [FURB109]: Replace `in [x, y, z]` with `in (x, y, z)`
IV_Swinger_PV_model.py:710:30 [FURB109]: Replace `in [x, y, z]` with `in (x, y, z)`
IV_Swinger_PV_model.py:716:30 [FURB109]: Replace `in [x, y, z]` with `in (x, y, z)`
IV_Swinger_PV_model.py:722:30 [FURB109]: Replace `in [x, y, z]` with `in (x, y, z)`
c51f144d
Fix refurb FURB138 suggestions (Issue #215)
by Chris Satterlee 1 year 11 months
Fix refurb FURB138 suggestions (Issue #215)

Fixed these:
IV_Swinger.py:448:13 [FURB138]: Consider using list comprehension
IV_Swinger2.py:1849:9 [FURB138]: Consider using list comprehension
IV_Swinger2.py:5463:13 [FURB138]: Consider using list comprehension
IV_Swinger2_gui.py:794:9 [FURB138]: Consider using list comprehension
IV_Swinger2_gui.py:2516:13 [FURB138]: Consider using list comprehension
IV_Swinger2_gui.py:9184:13 [FURB138]: Consider using list comprehension

Also found a few cases the tool didn't.
0699b3db
Add config.get() to __init__ (Issue #214)
by Chris Satterlee 1 year 11 months
Add config.get() to __init__ (Issue #214)

Added missing line to __init__
e30dfbc4
Next incremental batch of pathlib changes (Issue #...
by Chris Satterlee 1 year 11 months
Next incremental batch of pathlib changes (Issue #210)

This one is related to the previous commit in the sense that the changes are related to file access. It's not really specific to pathlib, however.

The biggest change is to remove most of the exception handling for file access from IV_Swinger2.py (and IV_Swinger_plotter.py.) Most such exceptions would just print and log an error message. But for anyone running the GUI, that wouldn't be very noticeable. Instead, it's better to just let the exceptions propagate up to the GUI and either handle them explicitly there, or let the catch-all exception handler generate the message with the exception text.

In IV_Swinger2_gui.py, the exceptions that are explicitly caught look for either PermissionError if that is specifically what is being checked for, or OSError, which is more general. IOError was merged into OSError in Python 3.3.
e10e79df
Next incremental batch of pathlib changes (Issue #...
by Chris Satterlee 1 year 11 months
Next incremental batch of pathlib changes (Issue #210)

Changed from glob.glob() to Path().glob()

Protected a few comparisions between Path() objects from generating false positives/negatives if one is actually a string by adding .resolve(). That would generate an exception if it's a string.

Replaced call to os.access() with a try/except.
2fb8c4fc
Next incremental batch of pathlib changes (Issue #...
by Chris Satterlee 1 year 11 months
Next incremental batch of pathlib changes (Issue #210)

This one mostly converts calls to open() to calls to the open() method or the Path object. However, some are replaced by calls to the read_text(), write_text(), or touch() methods.
869ec701
Next incremental batch of pathlib changes (Issue #...
by Chris Satterlee 1 year 11 months
Next incremental batch of pathlib changes (Issue #210)

This one converts the last few os.path usages in IV_Swinger_plotter.py to pathlib equivalents. It also adds the --plot_dir option to the plotter, which allows the removal of the os.chdir() call in the run() method of the IV_Swinger2_plotter class in IV_Swinger2.py.
cce7f81d
Report a bug