Skip to content

Commit 937e3eb

Browse files
committed
Put down some medium severity issues
1 parent 6a1ba23 commit 937e3eb

11 files changed

Lines changed: 27 additions & 23 deletions

File tree

Stoner/Zip.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from .folders.core import baseFolder
1919
from .folders.utils import pathjoin
2020
from .tools import copy_into, make_Data
21+
from .tools.file import get_filename
2122

2223

2324
def test_is_zip(filename, member=""):
@@ -120,8 +121,8 @@ def _extract(self, archive, member):
120121
self.filename = path.join(archive.filename, member)
121122
return self
122123

123-
def _load(self, filename=None, *args, **kargs):
124-
"""Load a file from the zip file, opening it as necessary."""
124+
def _load(self, *args, **kargs):
125+
filename, args, kargs = get_filename(args, kargs)
125126
if filename is None or not filename:
126127
self.get_filename("r")
127128
else:

Stoner/analysis/fitting/mixins.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ def _get_model_parnames(model):
333333
raise ValueError(
334334
"".join(
335335
[
336-
f"Unrecognised type for model! - should be lmfit.Model, scipy.odr.Model",
336+
"Unrecognised type for model! - should be lmfit.Model, scipy.odr.Model",
337337
f" or callable, not {type(model)}",
338338
]
339339
)

Stoner/formats/data/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
This sub-package is lazy-loaded but then pulls in all of the modules in order to register the routines.
44
"""
55

6-
__all__ = ["generic", "hdf5", "instruments", "facilities", "rigs", "simulations", "attocube", "maximus", "zip"]
6+
__all__ = ["generic", "hdf5", "instruments", "facilities", "rigs", "simulations", "attocube", "maximus", "zipped"]
77

8-
from . import generic, hdf5, instruments, facilities, rigs, simulations, attocube, maximus, zip
8+
from . import generic, hdf5, instruments, facilities, rigs, simulations, attocube, maximus, zip as zipped

Stoner/formats/maximus.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
from ..compat import string_types
2121
from ..HDF5 import HDFFileManager
2222
from ..tools.file import FileManager, get_filename
23-
from ..core.exceptions import StonerLoadError
2423

2524
SCAN_NO = re.compile(r"MPI_(\d+)")
2625

Stoner/plot/formats.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def __init__(self, *args, **kargs):
226226
# self.fig_width = None
227227
# self.fig_height = None
228228

229-
self.update(**kargs)
229+
self.update(kargs)
230230

231231
def __call__(self, **kargs):
232232
"""Call the template object can manipulate the rcParams that will be set."""
@@ -376,25 +376,25 @@ def clear(self):
376376
for attr in attrs:
377377
delattr(self, attr)
378378

379-
def update(self, *args, **kargs): # pylint: disable=signature-differs
379+
def update(self, other):
380380
"""Update the template with new attributes from keyword arguments.
381381
382382
Up to one positional argument may be supplied
383383
384384
Keyword arguments may be supplied to set default parameters. Any Matplotlib rc parameter
385385
may be specified, with .'s replaced with _ and )_ replaced with __.
386386
"""
387-
if len(args) == 1 and isinstance(args[0], Mapping):
388-
super().update(args[0])
389-
elif len(args) > 0:
390-
raise SyntaxError(
391-
"Only one posotional argument which should be a Mapping subclass can be supplied toi update."
392-
)
393-
for k in kargs:
394-
if k in dir(self) and not callable(self.__getattr__(k)):
395-
self.__setattr__(k, kargs[k])
396-
elif not k.startswith("_"):
397-
self.__setattr__("template_" + k, kargs[k])
387+
match other:
388+
case Mapping():
389+
for k, val in other.items():
390+
if k in dir(self) and not callable(self.__getattr__(k)):
391+
self.__setattr__(k, val)
392+
elif not k.startswith("_"):
393+
self.__setattr__("template_" + k, val)
394+
case _:
395+
raise SyntaxError(
396+
"Only one posotional argument which should be a Mapping subclass can be supplied toi update."
397+
)
398398

399399
def new_figure(self, figure=False, **kargs):
400400
"""Create a new figure.

Stoner/plot/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"auto_fit_fontsize",
4242
]
4343
import warnings
44-
from distutils.version import LooseVersion
44+
from looseversion import LooseVersion
4545

4646
import numpy as np
4747
import matplotlib.pyplot as plt

Stoner/tools/file.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def get_file_name_type(
110110
if isinstance(filetype, string_types): # We can specify filetype as part of name
111111
try:
112112
filetype = regexpDict(subclasses(parent))[filetype] # pylint: disable=E1136
113-
except KeyError:
113+
except KeyError as keyerr:
114114
parts = filetype.split(".")
115115
mod = ".".join(parts[:-1])
116116
try:
@@ -119,7 +119,7 @@ def get_file_name_type(
119119
except (ImportError, AttributeError) as err:
120120
raise ValueError(f"Unable to import {filetype}") from err
121121
if not issubclass(filetype, parent):
122-
raise ValueError(f"{filetype} is not a subclass of DataFile.")
122+
raise ValueError(f"{filetype} is not a subclass of DataFile.") from keyerr
123123
if filename is None or (isinstance(filename, bool) and not filename):
124124
if filetype is None:
125125
filetype = parent

doc/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ multiprocess
1212
asteval
1313
lmfit
1414
urllib3>=1.26
15+
looseversion>=1.0

recipe/meta.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ requirements:
4343
- dill >=0.2.8
4444
- urllib3 >=1.26
4545
- python-dateutil >=2.8
46+
- looseversion >=1.0
4647

4748

4849

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ multiprocess>=0.70
1717
dill>=0.2.8
1818
urllib3>=1.26
1919
dateutil>=2.8
20-
seaborn>=0.13
20+
seaborn>=0.13
21+
looseversion>=1.0

0 commit comments

Comments
 (0)