Skip to content

Commit

Permalink
reformat code using ruff 0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
SoulMelody committed Jan 9, 2025
1 parent 62bc94b commit 9866b7b
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ci:

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.6
rev: v0.9.0
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix, --show-fixes]
Expand Down
4 changes: 2 additions & 2 deletions libresvip/cli/commands/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ def print_plugin_details(plugin: FormatProviderPluginInfo) -> None:
if plugin.website:
typer.echo("\n" + _("Website: ") + plugin.website)
format_desc = f"{_(plugin.file_format)} (*.{plugin.suffix})"
typer.echo("\n" + f'{_("This plugin is applicable to")} {format_desc}.')
typer.echo("\n" + f"{_('This plugin is applicable to')} {format_desc}.")
typer.echo(
_(
"If you want to use this plugin, please specify '-i {}' (input) or '-o {}' (output) when converting."
).format(plugin.suffix.lower(), plugin.suffix.lower())
)
if plugin.description:
typer.echo(f'\n{_("Description: ")}\n{_(plugin.description)}')
typer.echo(f"\n{_('Description: ')}\n{_(plugin.description)}")
op_arr = [_("input"), _("output")]
options_arr = [
get_type_hints(plugin.plugin_object.load).get("options", None),
Expand Down
2 changes: 1 addition & 1 deletion libresvip/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def to_language(locale: str) -> str:
"""Turn a locale name (en_US) into a language name (en-us)."""
p = locale.find("_")
if p >= 0:
return f"{locale[:p].lower()}-{locale[p + 1:].lower()}"
return f"{locale[:p].lower()}-{locale[p + 1 :].lower()}"
else:
return locale.lower()

Expand Down
6 changes: 3 additions & 3 deletions libresvip/model/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,9 @@ def merge_projects(cls, projects: list[Project]) -> Project:
)

def split_tracks(self, max_track_count: int) -> list[Project]:
assert any(
isinstance(track, SingingTrack) for track in self.track_list
), "No singing tracks found"
assert any(isinstance(track, SingingTrack) for track in self.track_list), (
"No singing tracks found"
)
return [
self.model_copy(update={"track_list": track_chunk}, deep=True)
for track_chunk in more_itertools.chunked(
Expand Down
1 change: 1 addition & 0 deletions libresvip/plugins/json/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# noqa: A005
4 changes: 2 additions & 2 deletions libresvip/plugins/svp/param_expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,14 @@ class CurveGenerator(ParamExpression):
_interpolation: dataclasses.InitVar[
Callable[[float, tuple[float, float], tuple[float, float]], float]
]
_base_value: dataclasses.InitVar[int] = 0
_base_value: dataclasses.InitVar[int]
interval: Optional[portion.Interval] = None

def __post_init__(
self,
_point_list: Iterable[Point],
_interpolation: Callable[[float, tuple[float, float], tuple[float, float]], float],
_base_value: int = 0,
_base_value: int,
) -> None:
self.point_list = []
current_pos = -1
Expand Down
5 changes: 5 additions & 0 deletions libresvip/plugins/svp/synthv_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ def parse_param_curve(
for point in master_curve.points.root
],
_interpolation=self.parse_interpolation(master_curve.mode),
_base_value=0,
)
compound_expr = group_expr + master_expr
group_points = group_expr.point_list
Expand Down Expand Up @@ -266,6 +267,7 @@ def parse_pitch_curve(
for point in pitch_diff.points.root
],
_interpolation=self.parse_interpolation(pitch_diff.mode),
_base_value=0,
)
vibrato_env_expr: ParamExpression = CurveGenerator(
_point_list=[
Expand All @@ -288,6 +290,7 @@ def parse_pitch_curve(
for point in master_pitch_diff.points.root
],
_interpolation=self.parse_interpolation(master_pitch_diff.mode),
_base_value=0,
)
if master_vibrato_env is not None:
vibrato_env_expr += CurveGenerator(
Expand All @@ -299,6 +302,7 @@ def parse_pitch_curve(
for point in master_vibrato_env.points.root
],
_interpolation=self.parse_interpolation(vibrato_env.mode),
_base_value=0,
)
if self.options.instant:
instant_interval = RangeInterval(
Expand All @@ -321,6 +325,7 @@ def parse_pitch_curve(
for point in self.instant_pitch.points.root
],
_interpolation=self.parse_interpolation(self.instant_pitch.mode),
_base_value=0,
)
interval = RangeInterval(
[
Expand Down
2 changes: 1 addition & 1 deletion libresvip/plugins/vspx/vspx_interval_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class BasePitchCurve:
def __post_init__(
self,
note_track: VocalSharpNoteTrack,
default_trill: Optional[VocalSharpDefaultTrill] = None,
default_trill: Optional[VocalSharpDefaultTrill],
) -> None:
if not len(note_track.note):
pass
Expand Down
6 changes: 3 additions & 3 deletions libresvip/tui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ def compose(self) -> ComposeResult:
plugin_info = plugin_manager.plugin_registry[self.plugin_id]
with Vertical():
yield Label(plugin_info.name, classes="title")
yield Label(f'{_("Version: ")}{plugin_info.version}')
yield Link(f'{_("Author: ")}{_(plugin_info.author)}', url=plugin_info.website)
yield Label(f"{_('Version: ')}{plugin_info.version}")
yield Link(f"{_('Author: ')}{_(plugin_info.author)}", url=plugin_info.website)
yield Label(_("Introduction"))
yield Markdown(_(plugin_info.description))
with Horizontal():
Expand Down Expand Up @@ -934,7 +934,7 @@ def compose(self) -> ComposeResult:
url="https://github.com/SoulMelody/LibreSVIP",
tooltip=_("Repo URL"),
)
yield Label(f'{_("Version: ")}{libresvip.__version__} 🔖')
yield Label(f"{_('Version: ')}{libresvip.__version__} 🔖")
yield Link(
_("Author: SoulMelody") + " 🌐",
url="https://space.bilibili.com/175862486",
Expand Down
6 changes: 3 additions & 3 deletions libresvip/web/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -1964,7 +1964,7 @@ def tasks_area() -> None:
js_handler=f"""(event) => {{
for (let file of event.dataTransfer.files) {{
let file_name = file.name
post_form('{uploader.props['url']}', {{
post_form('{uploader.props["url"]}', {{
file_name: file
}})
}}
Expand Down Expand Up @@ -2037,7 +2037,7 @@ def tasks_area() -> None:
js_handler=f"""(event) => {{
for (let file of event.dataTransfer.files) {{
let file_name = file.name
post_form('{uploader.props['url']}', {{
post_form('{uploader.props["url"]}', {{
file_name: file
}})
}}
Expand Down Expand Up @@ -2217,7 +2217,7 @@ def add_javascript() -> None:
for (const fileHandle of fileHandles) {{
const file = await fileHandle.getFile();
let file_name = file.name
post_form('{uploader.props['url']}', {{
post_form('{uploader.props["url"]}', {{
file_name: file
}})
}}
Expand Down
5 changes: 1 addition & 4 deletions tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,7 @@ def test_ps_project_read(shared_datadir: pathlib.Path) -> None:

proj_path = shared_datadir / "test.ps_project"
with AESZipFile(
io.BytesIO(proj_path.read_bytes()),
"r",
compression=ZIP_STORED,
encryption=WZ_AES
io.BytesIO(proj_path.read_bytes()), "r", compression=ZIP_STORED, encryption=WZ_AES
) as zf:
zf.setpassword(b"a022ab39cb3b7b1de92ee441978c9e08")
rich.print(zf.read("config.json"))

0 comments on commit 9866b7b

Please sign in to comment.