Skip to content
Snippets Groups Projects
Commit 40961b1d authored by I. Nüske's avatar I. Nüske
Browse files

MNT: Fix various pylint errors:

- Remove unnecessary pass, init without effect, unused variables
- Update use of deprecated methods
- Fix used exception not matching documentation
- Ignore logging-fstring-interpolation, variant of logging-format-interpolation
parent 36951518
Branches
Tags
2 merge requests!128MNT: Added a warning when column metadata is not configured, and a better...,!126Fix pylint errors
......@@ -19,4 +19,5 @@ init-hook=
disable=
fixme,
logging-format-interpolation,
logging-fstring-interpolation,
logging-not-lazy,
......@@ -94,7 +94,6 @@ class AbstractCache(ABC):
Increase this variable, when changes to the cache tables are made.
"""
pass
@abstractmethod
def create_cache(self):
......@@ -102,14 +101,12 @@ class AbstractCache(ABC):
Provide an overloaded function here that creates the cache in
the most recent version.
"""
pass
@abstractmethod
def get_default_file_name(self):
"""
Supply a default file name for the cache here.
"""
pass
def check_cache(self):
"""
......@@ -192,9 +189,6 @@ class IdentifiableCache(AbstractCache):
def get_default_file_name(self):
return "caosdb_identifiable_cache.db"
def __init__(self, db_file=None, force_creation=False):
super().__init__(db_file, force_creation)
def create_cache(self):
"""
Create a new SQLITE cache file in self.db_file.
......
......@@ -208,7 +208,6 @@ class AbstractCFood(object, metaclass=ABCMeta):
To be overwritten by subclasses
"""
pass
def attach(self, item):
self.attached_items.append(item)
......
......@@ -487,8 +487,8 @@ ____________________\n""".format(i+1, len(pending_changes)) + str(el[3]))
logger.error(err_msg)
logger.error('Crawler finished with Datamodel Errors')
elif errors_occured:
msg = "There were fatal errors during execution, please "
"contact the system administrator!"
msg = ("There were fatal errors during execution, please contact "
"the system administrator!")
if self.debug_file:
msg += "\nPlease provide the following path:\n{}".format(
......
......@@ -94,7 +94,7 @@ def import_xml(filename, rerun=False, interactive=True):
if not rerun:
for _, el in enumerate(files.values()):
r = el.insert(unique=False)
el.insert(unique=False)
else:
for _, el in enumerate(files.values()):
el.id = None
......
......@@ -122,7 +122,7 @@ def compile_file_list(caosdbignore: str, localpath: str) -> list[str]:
current_ignore = caosdbignore
non_ignored_files = []
ignore_files: list[tuple[str, str]] = []
for root, dirs, files in os.walk(localpath):
for root, _, files in os.walk(localpath):
# remove local ignore files that do no longer apply to the current subtree (branch switch)
while len(ignore_files) > 0 and not root.startswith(ignore_files[-1][0]):
os.remove(ignore_files[-1][1])
......
......@@ -633,7 +633,7 @@ debug : bool, optional
"""
for key, value in self.model.items():
for _, value in self.model.items():
if isinstance(value, db.Property):
dtype = value.datatype
......
......@@ -156,8 +156,8 @@ class WithREADME(object):
for f in sublist]
if len(flat_list) == 0:
LOGGER.warn("ATTENTION: the field {} does not reference any "
"known files".format(field.key))
LOGGER.warning(f"ATTENTION: the field {field.key} does not"
" reference any known files")
self.attached_filenames.extend(flat_list) # pylint: disable=no-member
......
......@@ -73,7 +73,7 @@ def from_table(spreadsheet, recordtype):
""" parses a pandas DataFrame to a list of records """
records = db.Container()
for idx, row in spreadsheet.iterrows():
for _, row in spreadsheet.iterrows():
rec = db.Record()
rec.add_parent(name=recordtype)
......
......@@ -235,7 +235,6 @@ def find_records_that_reference_ids(referenced_ids, rt="", step_size=50):
record_ids.update([exp.id for exp in exps])
except Exception as e:
print(e)
pass
index += step_size
......
......@@ -92,4 +92,4 @@ class WebUI_Formatter(logging.Formatter):
return wrap_bootstrap_alert("<b>CRITICAL ERROR:</b> " + text,
kind="danger")
else:
raise Exception("unknown level")
raise RuntimeError("unknown level")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment