Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sublime_lib/activity_indicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ViewTarget(StatusTarget):
def __init__(self, view: sublime.View, key: str | None = None) -> None:
self.view: sublime.View = view
if key is None:
self.key: str = '_{!s}'.format(uuid4())
self.key: str = f"_{uuid4()!s}"
else:
self.key = key

Expand Down
4 changes: 2 additions & 2 deletions sublime_lib/encodings.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def from_sublime(name: str) -> str:
try:
return SUBLIME_TO_STANDARD[name]
except KeyError:
raise ValueError("Unknown Sublime encoding {!r}.".format(name)) from None
raise ValueError(f"Unknown Sublime encoding {name!r}.") from None


def to_sublime(name: str) -> str:
Expand All @@ -40,7 +40,7 @@ def to_sublime(name: str) -> str:
try:
return STANDARD_TO_SUBLIME[lookup(name).name]
except LookupError:
raise ValueError("Unknown Python encoding {!r}.".format(name)) from None
raise ValueError(f"Unknown Python encoding {name!r}.") from None


SUBLIME_TO_STANDARD = {
Expand Down
8 changes: 4 additions & 4 deletions sublime_lib/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ def autodoc(prefix: str | None = None) -> Callable[[EnumMeta], EnumMeta]:

def decorator(enum: EnumMeta) -> EnumMeta:
enum.__doc__ = (getdoc(enum) or '') + '\n\n' + '\n'.join([
cleandoc("""
cleandoc(f"""
.. py:attribute:: {name}
:annotation: = sublime.{pre}{name}
""").format(name=name, pre=prefix_str) for name in enum.__members__
:annotation: = sublime.{prefix_str}{name}
""") for name in enum.__members__
])

return enum
Expand Down Expand Up @@ -244,7 +244,7 @@ class HoverLocation(IntEnum):


def regex_match(value: str, operand: str) -> bool:
expr = r'(?:{})\Z'.format(operand)
expr = rf"(?:{operand})\Z"
return re.match(expr, value) is not None


Expand Down
2 changes: 1 addition & 1 deletion sublime_lib/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __init__(self, window: sublime.Window, panel_name: str):

def _checkExists(self) -> None:
if not self.exists():
raise ValueError("Panel {} does not exist.".format(self.panel_name))
raise ValueError(f"Panel {self.panel_name} does not exist.")

@define_guard
def guard_exists(self) -> None:
Expand Down
12 changes: 5 additions & 7 deletions sublime_lib/resource_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,7 @@ def from_file_path(cls, file_path: Path | str) -> ResourcePath:
if path:
return path
else:
raise ValueError(
"Path {!r} does not correspond to any resource path.".format(file_path)
)
raise ValueError(f"Path {file_path!r} does not correspond to any resource path.")

def __init__(self, *pathsegments: object):
"""
Expand Down Expand Up @@ -234,7 +232,7 @@ def __hash__(self) -> int:
return hash(self.parts)

def __repr__(self) -> str:
return "{}({!r})".format(self.__class__.__name__, str(self))
return f"{self.__class__.__name__}({self!s})"

def __str__(self) -> str:
return '/'.join(self.parts)
Expand Down Expand Up @@ -365,7 +363,7 @@ def relative_to(self, *other: object) -> tuple[str, ...]:
if other_path.parts == self._parts[:other_len]:
return self._parts[other_len:]
else:
raise ValueError("{!s} does not start with {!s}".format(self, other_path))
raise ValueError(f"{self!s} does not start with {other_path!s}")

def with_name(self, name: str) -> ResourcePath:
"""
Expand Down Expand Up @@ -422,7 +420,7 @@ def remove_suffix(
if new_name is not None:
return self.with_name(new_name)
elif must_remove:
raise ValueError('Cannot remove suffix {!r} from {!r}.'.format(suffix, self))
raise ValueError(f"Cannot remove suffix {suffix!r} from {self!r}.")
else:
return self

Expand Down Expand Up @@ -455,7 +453,7 @@ def file_path(self) -> Path:
except ValueError:
continue

raise ValueError("Can't find a filesystem path for {!r}.".format(self.root)) from None
raise ValueError(f"Can't find a filesystem path for {self.root!r}.") from None

def exists(self) -> bool:
"""
Expand Down
Loading