Skip to content

Commit

Permalink
refact: use Path.
Browse files Browse the repository at this point in the history
  • Loading branch information
sfermigier committed Nov 5, 2024
1 parent a1fa821 commit 175af1e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 0 additions & 2 deletions ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/abilian/core/models/attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
8 changes: 4 additions & 4 deletions src/abilian/web/assets/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -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"]):
Expand All @@ -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)


Expand Down

0 comments on commit 175af1e

Please sign in to comment.