diff --git a/ruff.toml b/ruff.toml index d5892e4..6567cdb 100644 --- a/ruff.toml +++ b/ruff.toml @@ -32,7 +32,6 @@ lint.extend-ignore = [ "S320", # OK, we're using defusedxml # Fix these (if possible / reasonable) - "B024", # `...` is an abstract base class, but it has no abstract methods "B027", # `...` is an empty method in an abstract base class, but has no abstract decorator "B028", # No explicit `...` keyword argument found "BLE001", # Do not catch blind exception @@ -56,7 +55,6 @@ lint.extend-ignore = [ "N806", # Variable in function should be lowercase # "PD011", # Use `.to_numpy()` instead of `.values` - "PERF203", # `try`-`except` within a loop incurs performance overhead "PLC0206", # Extracting value from dictionary without calling `.items()` "PLC0415", # `import` should be at the top-level of a file "PLC1901", # `x == ""` can be simplified to `not x` as an empty string is falsey diff --git a/src/abilian/core/models/attachment.py b/src/abilian/core/models/attachment.py index e2f44b9..fb5c6b1 100644 --- a/src/abilian/core/models/attachment.py +++ b/src/abilian/core/models/attachment.py @@ -19,8 +19,8 @@ ATTRIBUTE = "__attachments__" -class SupportsAttachment(abc.ABC): - pass +class SupportsAttachment(abc.ABC): # noqa: B024 + """Mixin for entities that can have attachments.""" def register(cls): diff --git a/src/abilian/web/assets/filters.py b/src/abilian/web/assets/filters.py index 582153d..25ef937 100644 --- a/src/abilian/web/assets/filters.py +++ b/src/abilian/web/assets/filters.py @@ -355,7 +355,7 @@ def output(self, _in, out, **kw): name = smap_path.name out.write(f"//# sourceMappingURL={name!s}") - self.fix_source_map_urls(str(smap_path)) + self.fix_source_map_urls(smap_path) def fix_url(self, cur_path, src_path): possible_paths = [p for p in self.ctx.url_mapping if src_path.startswith(p)] @@ -374,8 +374,8 @@ def fix_url(self, cur_path, src_path): path = possible_paths[0] return self.ctx.url_mapping[path] + src_path[len(path) :] - def fix_source_map_urls(self, filename): - with open(filename) as f: + def fix_source_map_urls(self, file_path: Path): + with file_path.open() as f: data = json.load(f) for idx, path in enumerate(data["sources"]): @@ -385,7 +385,7 @@ def fix_source_map_urls(self, filename): data["sources"][idx] = self.fix_url(self.ctx.directory, path) - with open(filename, "w") as f: + with file_path.open("w") as f: json.dump(data, f)