Skip to content

Commit

Permalink
chore: ruff commit hook upgrade, typing and linter fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
volfpeter committed Dec 20, 2024
1 parent 9df1201 commit dc9921e
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.3.5
rev: v0.8.4
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ pyclean = "^2.0.0"
[tool.ruff]
lint.ignore = ["B027", "B905", "C901", "E402", "E501", "E731"]
lint.select = ["B", "C", "E", "F", "W"]
extend-exclude = ["src/modules/sbstudio/vendor"]
extend-exclude = [
"src/modules/sbstudio/vendor",
"src/modules/sbstudio/i18n/translations.py"
]

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down
27 changes: 8 additions & 19 deletions src/modules/sbstudio/plugin/model/light_effects.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,10 @@
import types
import bpy

from collections.abc import Callable, Iterable, Sequence
from functools import partial
from operator import itemgetter
from typing import (
cast,
Callable,
Iterable,
List,
Optional,
Sequence,
Tuple,
TYPE_CHECKING,
)
from typing import cast, Optional

from bpy.path import abspath
from bpy.props import (
Expand Down Expand Up @@ -54,9 +46,6 @@

from .mixins import ListMixin

if TYPE_CHECKING:
from sbstudio.api.types import Mapping
from sbstudio.plugin.model import StoryboardEntry

__all__ = ("ColorFunctionProperties", "LightEffect", "LightEffectCollection")

Expand Down Expand Up @@ -159,8 +148,8 @@ def test_is_in_front_of(plane: Optional[Plane], point: Coordinate3D) -> bool:
_always_true = constant(True)


def get_color_function_names(self, context: Context) -> List[Tuple[str, str, str]]:
names: List[str]
def get_color_function_names(self, context: Context) -> list[tuple[str, str, str]]:
names: list[str]

if self.path:
absolute_path = abspath(self.path)
Expand Down Expand Up @@ -398,7 +387,7 @@ def apply_on_colors(
self,
colors: Sequence[MutableRGBAColor],
positions: Sequence[Coordinate3D],
mapping: Optional[List[int]],
mapping: Optional[list[int]],
*,
frame: int,
random_seq: RandomSequence,
Expand All @@ -422,7 +411,7 @@ def get_output_based_on_output_type(
output_type: str,
mapping_mode: str,
output_function,
) -> Tuple[Optional[List[Optional[float]]], Optional[float]]:
) -> tuple[Optional[list[Optional[float]]], Optional[float]]:
"""Get the float output(s) for color ramp or image indexing based on the output type.
Args:
Expand All @@ -432,9 +421,9 @@ def get_output_based_on_output_type(
Returns:
individual and common outputs
"""
outputs: Optional[List[Optional[float]]] = None
outputs: Optional[list[Optional[float]]] = None
common_output: Optional[float] = None
order: Optional[List[int]] = None
order: Optional[list[int]] = None

if output_type == "FIRST_COLOR":
common_output = 0.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
from __future__ import annotations

from typing import TYPE_CHECKING

from .base import StoryboardOperator

if TYPE_CHECKING:
from bpy.types import Context

from sbstudio.plugin.model.storyboard import Storyboard

__all__ = ("CreateNewStoryboardEntryOperator",)


Expand All @@ -10,6 +19,6 @@ class CreateNewStoryboardEntryOperator(StoryboardOperator):
bl_label = "Create New Storyboard Entry"
bl_description = "Creates a new storyboard entry at the end of the storyboard."

def execute_on_storyboard(self, storyboard, context):
def execute_on_storyboard(self, storyboard: Storyboard, context: Context):
storyboard.add_new_entry(name="Untitled", select=True)
return {"FINISHED"}
2 changes: 1 addition & 1 deletion src/modules/sbstudio/plugin/operators/prepare.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from bpy.types import Operator

from sbstudio.plugin.constants import Collections, Templates
from sbstudio.plugin.constants import Collections
from sbstudio.plugin.objects import link_object_to_scene
from sbstudio.plugin.state import get_file_specific_state

Expand Down
15 changes: 12 additions & 3 deletions src/modules/sbstudio/plugin/operators/remove_storyboard_entry.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
from __future__ import annotations

from typing import TYPE_CHECKING

from sbstudio.plugin.constants import Collections
from sbstudio.plugin.model.storyboard import get_storyboard
from sbstudio.plugin.utils.transition import find_transition_constraint_between

from .base import StoryboardOperator

if TYPE_CHECKING:
from bpy.types import Context

from sbstudio.plugin.model.storyboard import Storyboard, StoryboardEntry

__all__ = ("RemoveStoryboardEntryOperator",)


Expand All @@ -15,19 +24,19 @@ class RemoveStoryboardEntryOperator(StoryboardOperator):
bl_description = "Remove the selected entry from the storyboard"

@classmethod
def poll(cls, context):
def poll(cls, context: Context):
return (
StoryboardOperator.poll(context)
and get_storyboard(context=context).active_entry is not None
)

def execute_on_storyboard(self, storyboard, context):
def execute_on_storyboard(self, storyboard: Storyboard, context: Context):
remove_constraints_for_storyboard_entry(storyboard.active_entry)
storyboard.remove_active_entry()
return {"FINISHED"}


def remove_constraints_for_storyboard_entry(entry):
def remove_constraints_for_storyboard_entry(entry: StoryboardEntry):
if not entry:
return

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from numpy import array, float32
from typing import Literal

from bpy.types import Context, Operator
Expand Down
1 change: 0 additions & 1 deletion src/modules/sbstudio/plugin/tasks/light_effects.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

if TYPE_CHECKING:
from bpy.types import Depsgraph, Scene
from sbstudio.api.types import Mapping

__all__ = ("UpdateLightEffectsTask",)

Expand Down

0 comments on commit dc9921e

Please sign in to comment.