mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 12:54:40 +01:00
don't use 'annotations' import in pyblish plugins
This commit is contained in:
parent
f0abcb9ee7
commit
cd344e6710
2 changed files with 30 additions and 32 deletions
|
|
@ -1,4 +1,3 @@
|
|||
from __future__ import annotations
|
||||
import os
|
||||
import re
|
||||
import copy
|
||||
|
|
@ -52,7 +51,7 @@ class TempData:
|
|||
pixel_aspect: float
|
||||
resolution_width: int
|
||||
resolution_height: int
|
||||
origin_repre: dict[str, Any]
|
||||
origin_repre: "dict[str, Any]"
|
||||
input_is_sequence: bool
|
||||
first_sequence_frame: int
|
||||
input_allow_bg: bool
|
||||
|
|
@ -60,12 +59,12 @@ class TempData:
|
|||
without_handles: bool
|
||||
handles_are_set: bool
|
||||
input_ext: str
|
||||
explicit_input_paths: list[str]
|
||||
paths_to_remove: list[str]
|
||||
explicit_input_paths: "list[str]"
|
||||
paths_to_remove: "list[str]"
|
||||
|
||||
# Set later
|
||||
full_output_path: str = ""
|
||||
filled_files: dict[int, str] = field(default_factory=dict)
|
||||
filled_files: "dict[int, str]" = field(default_factory=dict)
|
||||
output_ext_is_image: bool = True
|
||||
output_is_sequence: bool = True
|
||||
|
||||
|
|
@ -1020,7 +1019,7 @@ class ExtractReview(pyblish.api.InstancePlugin):
|
|||
current_repre_name: str,
|
||||
start_frame: int,
|
||||
end_frame: int
|
||||
) -> Optional[dict[int, str]]:
|
||||
) -> Optional["dict[int, str]"]:
|
||||
"""Tries to replace missing frames from ones from last version"""
|
||||
repre_file_paths = self._get_last_version_files(
|
||||
instance, current_repre_name)
|
||||
|
|
@ -1108,7 +1107,7 @@ class ExtractReview(pyblish.api.InstancePlugin):
|
|||
resolution_height: int,
|
||||
extension: str,
|
||||
temp_data: TempData
|
||||
) -> Optional[dict[int, str]]:
|
||||
) -> Optional["dict[int, str]"]:
|
||||
"""Fills missing files by blank frame."""
|
||||
|
||||
blank_frame_path = None
|
||||
|
|
@ -1164,7 +1163,7 @@ class ExtractReview(pyblish.api.InstancePlugin):
|
|||
staging_dir: str,
|
||||
start_frame: int,
|
||||
end_frame: int
|
||||
) -> dict[int, str]:
|
||||
) -> "dict[int, str]":
|
||||
"""Fill missing files in sequence by duplicating existing ones.
|
||||
|
||||
This will take nearest frame file and copy it with so as to fill
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
"""Integrate representations with traits."""
|
||||
from __future__ import annotations
|
||||
|
||||
import contextlib
|
||||
import copy
|
||||
import hashlib
|
||||
|
|
@ -87,7 +85,7 @@ class TransferItem:
|
|||
size: int
|
||||
checksum: str
|
||||
template: str
|
||||
template_data: dict[str, Any]
|
||||
template_data: "dict[str, Any]"
|
||||
representation: Representation
|
||||
related_trait: FileLocation
|
||||
|
||||
|
|
@ -134,7 +132,7 @@ class TemplateItem:
|
|||
"""
|
||||
anatomy: Anatomy
|
||||
template: str
|
||||
template_data: dict[str, Any]
|
||||
template_data: "dict[str, Any]"
|
||||
template_object: AnatomyTemplateItem
|
||||
|
||||
|
||||
|
|
@ -144,14 +142,14 @@ class RepresentationEntity:
|
|||
id: str
|
||||
versionId: str # noqa: N815
|
||||
name: str
|
||||
files: dict[str, Any]
|
||||
attrib: dict[str, Any]
|
||||
files: "dict[str, Any]"
|
||||
attrib: "dict[str, Any]"
|
||||
data: str
|
||||
tags: list[str]
|
||||
tags: "list[str]"
|
||||
status: str
|
||||
|
||||
|
||||
def get_instance_families(instance: pyblish.api.Instance) -> list[str]:
|
||||
def get_instance_families(instance: pyblish.api.Instance) -> "list[str]":
|
||||
"""Get all families of the instance.
|
||||
|
||||
Todo:
|
||||
|
|
@ -177,7 +175,7 @@ def get_instance_families(instance: pyblish.api.Instance) -> list[str]:
|
|||
|
||||
|
||||
def get_changed_attributes(
|
||||
old_entity: dict, new_entity: dict) -> (dict[str, Any]):
|
||||
old_entity: dict, new_entity: dict) -> ("dict[str, Any]"):
|
||||
"""Prepare changes for entity update.
|
||||
|
||||
Todo:
|
||||
|
|
@ -212,7 +210,7 @@ def get_changed_attributes(
|
|||
return changes
|
||||
|
||||
|
||||
def prepare_for_json(data: dict[str, Any]) -> dict[str, Any]:
|
||||
def prepare_for_json(data: "dict[str, Any]") -> "dict[str, Any]":
|
||||
"""Prepare data for JSON serialization.
|
||||
|
||||
If there are values that json cannot serialize, this function will
|
||||
|
|
@ -354,7 +352,7 @@ class IntegrateTraits(pyblish.api.InstancePlugin):
|
|||
def get_transfers_from_representations(
|
||||
self,
|
||||
instance: pyblish.api.Instance,
|
||||
representations: list[Representation]) -> list[TransferItem]:
|
||||
representations: "list[Representation]") -> "list[TransferItem]":
|
||||
"""Get transfers from representations.
|
||||
|
||||
This method will go through all representations and prepare transfers
|
||||
|
|
@ -376,7 +374,7 @@ class IntegrateTraits(pyblish.api.InstancePlugin):
|
|||
"""
|
||||
template: str = self.get_publish_template(instance)
|
||||
instance_template_data: dict[str, str] = {}
|
||||
transfers: list[TransferItem] = []
|
||||
transfers: "list[TransferItem]" = []
|
||||
# prepare template and data to format it
|
||||
for representation in representations:
|
||||
|
||||
|
|
@ -471,7 +469,8 @@ class IntegrateTraits(pyblish.api.InstancePlugin):
|
|||
|
||||
@staticmethod
|
||||
def filter_lifecycle(
|
||||
representations: list[Representation]) -> list[Representation]:
|
||||
representations: "list[Representation]"
|
||||
) -> "list[Representation]":
|
||||
"""Filter representations based on LifeCycle traits.
|
||||
|
||||
Args:
|
||||
|
|
@ -887,7 +886,7 @@ class IntegrateTraits(pyblish.api.InstancePlugin):
|
|||
def get_transfers_from_file_locations(
|
||||
representation: Representation,
|
||||
template_item: TemplateItem,
|
||||
transfers: list[TransferItem]) -> None:
|
||||
transfers: "list[TransferItem]") -> None:
|
||||
"""Get transfers from FileLocations trait.
|
||||
|
||||
Args:
|
||||
|
|
@ -928,7 +927,7 @@ class IntegrateTraits(pyblish.api.InstancePlugin):
|
|||
def get_transfers_from_sequence(
|
||||
representation: Representation,
|
||||
template_item: TemplateItem,
|
||||
transfers: list[TransferItem]
|
||||
transfers: "list[TransferItem]"
|
||||
) -> None:
|
||||
"""Get transfers from Sequence trait.
|
||||
|
||||
|
|
@ -949,7 +948,7 @@ class IntegrateTraits(pyblish.api.InstancePlugin):
|
|||
# template is higher, us the one from the template
|
||||
dst_padding = representation.get_trait(
|
||||
Sequence).frame_padding
|
||||
frames: list[int] = sequence.get_frame_list(
|
||||
frames: "list[int]" = sequence.get_frame_list(
|
||||
representation.get_trait(FileLocations),
|
||||
regex=sequence.frame_regex)
|
||||
template_padding = template_item.anatomy.templates_obj.frame_padding
|
||||
|
|
@ -1000,7 +999,7 @@ class IntegrateTraits(pyblish.api.InstancePlugin):
|
|||
def get_transfers_from_udim(
|
||||
representation: Representation,
|
||||
template_item: TemplateItem,
|
||||
transfers: list[TransferItem]
|
||||
transfers: "list[TransferItem]"
|
||||
) -> None:
|
||||
"""Get transfers from UDIM trait.
|
||||
|
||||
|
|
@ -1056,7 +1055,7 @@ class IntegrateTraits(pyblish.api.InstancePlugin):
|
|||
def get_transfers_from_file_location(
|
||||
representation: Representation,
|
||||
template_item: TemplateItem,
|
||||
transfers: list[TransferItem]
|
||||
transfers: "list[TransferItem]"
|
||||
) -> None:
|
||||
"""Get transfers from FileLocation trait.
|
||||
|
||||
|
|
@ -1114,7 +1113,7 @@ class IntegrateTraits(pyblish.api.InstancePlugin):
|
|||
def get_transfers_from_bundle(
|
||||
representation: Representation,
|
||||
template_item: TemplateItem,
|
||||
transfers: list[TransferItem]
|
||||
transfers: "list[TransferItem]"
|
||||
) -> None:
|
||||
"""Get transfers from Bundle trait.
|
||||
|
||||
|
|
@ -1152,7 +1151,7 @@ class IntegrateTraits(pyblish.api.InstancePlugin):
|
|||
)
|
||||
|
||||
def _prepare_file_info(
|
||||
self, path: Path, anatomy: Anatomy) -> dict[str, Any]:
|
||||
self, path: Path, anatomy: Anatomy) -> "dict[str, Any]":
|
||||
"""Prepare information for one file (asset or resource).
|
||||
|
||||
Arguments:
|
||||
|
|
@ -1181,10 +1180,10 @@ class IntegrateTraits(pyblish.api.InstancePlugin):
|
|||
|
||||
def _get_legacy_files_for_representation(
|
||||
self,
|
||||
transfer_items: list[TransferItem],
|
||||
transfer_items: "list[TransferItem]",
|
||||
representation: Representation,
|
||||
anatomy: Anatomy,
|
||||
) -> list[dict[str, str]]:
|
||||
) -> "list[dict[str, str]]":
|
||||
"""Get legacy files for a given representation.
|
||||
|
||||
This expects the file to exist - it must run after the transfer
|
||||
|
|
@ -1194,13 +1193,13 @@ class IntegrateTraits(pyblish.api.InstancePlugin):
|
|||
list: List of legacy files.
|
||||
|
||||
"""
|
||||
selected: list[TransferItem] = []
|
||||
selected: "list[TransferItem]" = []
|
||||
selected.extend(
|
||||
item
|
||||
for item in transfer_items
|
||||
if item.representation == representation
|
||||
)
|
||||
files: list[dict[str, str]] = []
|
||||
files: "list[dict[str, str]]" = []
|
||||
files.extend(
|
||||
self._prepare_file_info(item.destination, anatomy)
|
||||
for item in selected
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue