Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Stricter ruff config #1022

Merged
merged 4 commits into from
Nov 25, 2024
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
4 changes: 2 additions & 2 deletions client/ayon_core/addon/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,8 +535,8 @@ def ensure_is_process_ready(
Implementation of this method is optional.

Note:
The logic can be similar to logic in tray, but tray does not require
to be logged in.
The logic can be similar to logic in tray, but tray does not
require to be logged in.

Args:
process_context (ProcessContext): Context of child
Expand Down
3 changes: 2 additions & 1 deletion client/ayon_core/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ def publish_report_viewer():
@main_cli.command()
@click.argument("output_path")
@click.option("--project", help="Define project context")
@click.option("--folder", help="Define folder in project (project must be set)")
@click.option(
"--folder", help="Define folder in project (project must be set)")
@click.option(
"--strict",
is_flag=True,
Expand Down
4 changes: 3 additions & 1 deletion client/ayon_core/lib/attribute_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,9 @@ def serialize(self):
return data

@staticmethod
def prepare_enum_items(items: "EnumItemsInputType") -> List["EnumItemDict"]:
def prepare_enum_items(
items: "EnumItemsInputType"
) -> List["EnumItemDict"]:
"""Convert items to unified structure.

Output is a list where each item is dictionary with 'value'
Expand Down
14 changes: 2 additions & 12 deletions client/ayon_core/lib/local_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,7 @@ def delete_item(self, name):
@abstractmethod
def _delete_item(self, name):
# type: (str) -> None
"""Delete item from settings.

Note:
see :meth:`ayon_core.lib.user_settings.ARegistrySettings.delete_item`

"""
"""Delete item from settings."""
pass

def __delitem__(self, name):
Expand Down Expand Up @@ -433,12 +428,7 @@ def delete_item_from_section(self, section, name):
config.write(cfg)

def _delete_item(self, name):
"""Delete item from default section.

Note:
See :meth:`~ayon_core.lib.IniSettingsRegistry.delete_item_from_section`

"""
"""Delete item from default section."""
self.delete_item_from_section("MAIN", name)


Expand Down
14 changes: 9 additions & 5 deletions client/ayon_core/pipeline/create/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -1283,12 +1283,16 @@ def bulk_value_changes(self, sender=None):

@contextmanager
def bulk_pre_create_attr_defs_change(self, sender=None):
with self._bulk_context("pre_create_attrs_change", sender) as bulk_info:
with self._bulk_context(
"pre_create_attrs_change", sender
) as bulk_info:
yield bulk_info

@contextmanager
def bulk_create_attr_defs_change(self, sender=None):
with self._bulk_context("create_attrs_change", sender) as bulk_info:
with self._bulk_context(
"create_attrs_change", sender
) as bulk_info:
yield bulk_info

@contextmanager
Expand Down Expand Up @@ -1946,9 +1950,9 @@ def remove_instances(self, instances, sender=None):
creator are just removed from context.

Args:
instances (List[CreatedInstance]): Instances that should be removed.
Remove logic is done using creator, which may require to
do other cleanup than just remove instance from context.
instances (List[CreatedInstance]): Instances that should be
removed. Remove logic is done using creator, which may require
to do other cleanup than just remove instance from context.
sender (Optional[str]): Sender of the event.

"""
Expand Down
6 changes: 5 additions & 1 deletion client/ayon_core/pipeline/create/product_name.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import ayon_api
from ayon_core.lib import StringTemplate, filter_profiles, prepare_template_data
from ayon_core.lib import (
StringTemplate,
filter_profiles,
prepare_template_data,
)
from ayon_core.settings import get_project_settings

from .constants import DEFAULT_PRODUCT_TEMPLATE
Expand Down
13 changes: 10 additions & 3 deletions client/ayon_core/pipeline/editorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ def remap_range_on_file_sequence(otio_clip, in_out_range):
source_range = otio_clip.source_range
available_range_rate = available_range.start_time.rate
media_in = available_range.start_time.value
available_range_start_frame = (
available_range.start_time.to_frames()
)

# Temporary.
# Some AYON custom OTIO exporter were implemented with relative
Expand All @@ -230,7 +233,7 @@ def remap_range_on_file_sequence(otio_clip, in_out_range):
# while we are updating those.
if (
is_clip_from_media_sequence(otio_clip)
and otio_clip.available_range().start_time.to_frames() == media_ref.start_frame
and available_range_start_frame == media_ref.start_frame
and source_range.start_time.to_frames() < media_ref.start_frame
):
media_in = 0
Expand Down Expand Up @@ -303,8 +306,12 @@ def get_media_range_with_retimes(otio_clip, handle_start, handle_end):
rounded_av_rate = round(available_range_rate, 2)
rounded_src_rate = round(source_range.start_time.rate, 2)
if rounded_av_rate != rounded_src_rate:
conformed_src_in = source_range.start_time.rescaled_to(available_range_rate)
conformed_src_duration = source_range.duration.rescaled_to(available_range_rate)
conformed_src_in = source_range.start_time.rescaled_to(
available_range_rate
)
conformed_src_duration = source_range.duration.rescaled_to(
available_range_rate
)
conformed_source_range = otio.opentime.TimeRange(
start_time=conformed_src_in,
duration=conformed_src_duration
Expand Down
6 changes: 3 additions & 3 deletions client/ayon_core/pipeline/entity_uri.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ def parse_ayon_entity_uri(uri: str) -> Optional[dict]:

Example:
>>> parse_ayon_entity_uri(
>>> "ayon://test/char/villain?product=modelMain&version=2&representation=usd" # noqa: E501
>>> "ayon://test/char/villain?product=modelMain&version=2&representation=usd"
>>> )
{'project': 'test', 'folderPath': '/char/villain',
'product': 'modelMain', 'version': 1,
'representation': 'usd'}
>>> parse_ayon_entity_uri(
>>> "ayon+entity://project/folder?product=renderMain&version=3&representation=exr" # noqa: E501
>>> "ayon+entity://project/folder?product=renderMain&version=3&representation=exr"
>>> )
{'project': 'project', 'folderPath': '/folder',
'product': 'renderMain', 'version': 3,
Expand All @@ -34,7 +34,7 @@ def parse_ayon_entity_uri(uri: str) -> Optional[dict]:
dict[str, Union[str, int]]: The individual key with their values as
found in the ayon entity URI.

"""
""" # noqa: E501

if not (uri.startswith("ayon+entity://") or uri.startswith("ayon://")):
return {}
Expand Down
20 changes: 15 additions & 5 deletions client/ayon_core/pipeline/farm/pyblish_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
import ayon_api
import clique
from ayon_core.lib import Logger, collect_frames
from ayon_core.pipeline import get_current_project_name, get_representation_path
from ayon_core.pipeline import (
get_current_project_name,
get_representation_path,
)
from ayon_core.pipeline.create import get_product_name
from ayon_core.pipeline.farm.patterning import match_aov_pattern
from ayon_core.pipeline.publish import KnownPublishError
Expand Down Expand Up @@ -771,9 +774,14 @@ def _create_instances_for_aov(instance, skeleton, aov_filter, additional_data,

project_settings = instance.context.data.get("project_settings")

use_legacy_product_name = True
try:
use_legacy_product_name = project_settings["core"]["tools"]["creator"]["use_legacy_product_names_for_renders"] # noqa: E501
use_legacy_product_name = (
project_settings
["core"]
["tools"]
["creator"]
["use_legacy_product_names_for_renders"]
)
except KeyError:
warnings.warn(
("use_legacy_for_renders not found in project settings. "
Expand All @@ -789,7 +797,9 @@ def _create_instances_for_aov(instance, skeleton, aov_filter, additional_data,
dynamic_data=dynamic_data)

else:
product_name, group_name = get_product_name_and_group_from_template(
(
product_name, group_name
) = get_product_name_and_group_from_template(
task_entity=instance.data["taskEntity"],
project_name=instance.context.data["projectName"],
host_name=instance.context.data["hostName"],
Expand Down Expand Up @@ -932,7 +942,7 @@ def _collect_expected_files_for_aov(files):
# but we really expect only one collection.
# Nothing else make sense.
if len(cols) != 1:
raise ValueError("Only one image sequence type is expected.") # noqa: E501
raise ValueError("Only one image sequence type is expected.")
return list(cols[0])


Expand Down
3 changes: 2 additions & 1 deletion client/ayon_core/plugins/publish/collect_hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ def process(self, context):

shot_data = {
"entity_type": "folder",
# WARNING unless overwritten, default folder type is hardcoded to shot
# WARNING unless overwritten, default folder type is hardcoded
# to shot
"folder_type": instance.data.get("folder_type") or "Shot",
"tasks": instance.data.get("tasks") or {},
"comments": instance.data.get("comments", []),
Expand Down
31 changes: 20 additions & 11 deletions client/ayon_core/plugins/publish/extract_otio_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,26 +129,33 @@ def process(self, instance):
res_data[key] = value
break

self.to_width, self.to_height = res_data["width"], res_data["height"]
self.log.debug("> self.to_width x self.to_height: {} x {}".format(
self.to_width, self.to_height
))
self.to_width, self.to_height = (
res_data["width"], res_data["height"]
)
self.log.debug(
"> self.to_width x self.to_height:"
f" {self.to_width} x {self.to_height}"
)

available_range = r_otio_cl.available_range()
available_range_start_frame = (
available_range.start_time.to_frames()
)
processing_range = None
self.actual_fps = available_range.duration.rate
start = src_range.start_time.rescaled_to(self.actual_fps)
duration = src_range.duration.rescaled_to(self.actual_fps)
src_frame_start = src_range.start_time.to_frames()

# Temporary.
# Some AYON custom OTIO exporter were implemented with relative
# source range for image sequence. Following code maintain
# backward-compatibility by adjusting available range
# Some AYON custom OTIO exporter were implemented with
# relative source range for image sequence. Following code
# maintain backward-compatibility by adjusting available range
# while we are updating those.
if (
is_clip_from_media_sequence(r_otio_cl)
and available_range.start_time.to_frames() == media_ref.start_frame
and src_range.start_time.to_frames() < media_ref.start_frame
and available_range_start_frame == media_ref.start_frame
and src_frame_start < media_ref.start_frame
):
available_range = otio.opentime.TimeRange(
otio.opentime.RationalTime(0, rate=self.actual_fps),
Expand Down Expand Up @@ -246,7 +253,8 @@ def process(self, instance):
# Extraction via FFmpeg.
else:
path = media_ref.target_url
# Set extract range from 0 (FFmpeg ignores embedded timecode).
# Set extract range from 0 (FFmpeg ignores
# embedded timecode).
extract_range = otio.opentime.TimeRange(
otio.opentime.RationalTime(
(
Expand Down Expand Up @@ -414,7 +422,8 @@ def _render_segment(self, sequence=None,
to defined image sequence format.

Args:
sequence (list): input dir path string, collection object, fps in list
sequence (list): input dir path string, collection object,
fps in list.
video (list)[optional]: video_path string, otio_range in list
gap (int)[optional]: gap duration
end_offset (int)[optional]: offset gap frame start in frames
Expand Down
10 changes: 6 additions & 4 deletions client/ayon_core/plugins/publish/validate_unique_subsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class ValidateProductUniqueness(pyblish.api.ContextPlugin):
"""Validate all product names are unique.

This only validates whether the instances currently set to publish from
the workfile overlap one another for the folder + product they are publishing
to.
the workfile overlap one another for the folder + product they are
publishing to.

This does not perform any check against existing publishes in the database
since it is allowed to publish into existing products resulting in
Expand Down Expand Up @@ -72,8 +72,10 @@ def process(self, context):
# All is ok
return

msg = ("Instance product names {} are not unique. ".format(non_unique) +
"Please remove or rename duplicates.")
msg = (
f"Instance product names {non_unique} are not unique."
" Please remove or rename duplicates."
)
formatting_data = {
"non_unique": ",".join(non_unique)
}
Expand Down
17 changes: 11 additions & 6 deletions client/ayon_core/scripts/otio_burnin.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,25 +79,30 @@ class ModifiedBurnins(ffmpeg_burnins.Burnins):
- Datatypes explanation:
<color> string format must be supported by FFmpeg.
Examples: "#000000", "0x000000", "black"
<font> must be accesible by ffmpeg = name of registered Font in system or path to font file.
<font> must be accesible by ffmpeg = name of registered Font in system
or path to font file.
Examples: "Arial", "C:/Windows/Fonts/arial.ttf"

- Possible keys:
"opacity" - Opacity of text - <float, Range:0-1>
"bg_opacity" - Opacity of background (box around text) - <float, Range:0-1>
"bg_color" - Background color - <color>
"bg_padding" - Background padding in pixels - <int>
"x_offset" - offsets burnin vertically by entered pixels from border - <int>
"y_offset" - offsets burnin horizontally by entered pixels from border - <int>
"x_offset" - offsets burnin vertically by entered pixels
from border - <int>
"y_offset" - offsets burnin horizontally by entered pixels
from border - <int>
- x_offset & y_offset should be set at least to same value as bg_padding!!
"font" - Font Family for text - <font>
"font_size" - Font size in pixels - <int>
"font_color" - Color of text - <color>
"frame_offset" - Default start frame - <int>
- required IF start frame is not set when using frames or timecode burnins
- required IF start frame is not set when using frames
or timecode burnins

On initializing class can be set General options through "options_init" arg.
General can be overridden when adding burnin
On initializing class can be set General options through
"options_init" arg.
General options can be overridden when adding burnin.

'''
TOP_CENTERED = ffmpeg_burnins.TOP_CENTERED
Expand Down
3 changes: 2 additions & 1 deletion client/ayon_core/settings/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ def get_current_project_settings():
project_name = os.environ.get("AYON_PROJECT_NAME")
if not project_name:
raise ValueError(
"Missing context project in environemt variable `AYON_PROJECT_NAME`."
"Missing context project in environment"
" variable `AYON_PROJECT_NAME`."
)
return get_project_settings(project_name)
4 changes: 3 additions & 1 deletion client/ayon_core/tools/creator/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,9 @@ def __init__(self, parent=None):

product_type_label = QtWidgets.QLabel(self)
product_type_label.setObjectName("CreatorProductTypeLabel")
product_type_label.setAlignment(QtCore.Qt.AlignBottom | QtCore.Qt.AlignLeft)
product_type_label.setAlignment(
QtCore.Qt.AlignBottom | QtCore.Qt.AlignLeft
)

help_label = QtWidgets.QLabel(self)
help_label.setAlignment(QtCore.Qt.AlignTop | QtCore.Qt.AlignLeft)
Expand Down
6 changes: 3 additions & 3 deletions client/ayon_core/tools/launcher/models/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ class ApplicationAction(LauncherAction):

Application action based on 'ApplicationManager' system.

Handling of applications in launcher is not ideal and should be completely
redone from scratch. This is just a temporary solution to keep backwards
compatibility with AYON launcher.
Handling of applications in launcher is not ideal and should be
completely redone from scratch. This is just a temporary solution
to keep backwards compatibility with AYON launcher.

Todos:
Move handling of errors to frontend.
Expand Down
6 changes: 5 additions & 1 deletion client/ayon_core/tools/loader/ui/_multicombobox.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,11 @@ def _paint_items(self, painter, indexes, content_rect):
def setItemCheckState(self, index, state):
self.setItemData(index, state, QtCore.Qt.CheckStateRole)

def set_value(self, values: Optional[Iterable[Any]], role: Optional[int] = None):
def set_value(
self,
values: Optional[Iterable[Any]],
role: Optional[int] = None,
):
if role is None:
role = self._value_role

Expand Down
Loading
Loading