♻️ fixes

type hints, checks
This commit is contained in:
Ondrej Samohel 2025-11-26 17:25:10 +01:00
parent 00e2e3c2ad
commit e6007b2cee
No known key found for this signature in database
GPG key ID: 02376E18990A97C6
4 changed files with 18 additions and 24 deletions

View file

@ -766,6 +766,15 @@ class CreateContext:
"and skipping: %s", creator_identifier, creator_class
)
continue
if not creator_class.product_base_type:
warn(
f"Provided creator {creator_class!r} doesn't have "
"product base type attribute defined. This will be "
"required in future.",
DeprecationWarning,
stacklevel=2
)
continue
# Filter by host name
if (
@ -1236,15 +1245,6 @@ class CreateContext:
"""
creator = self._get_creator_in_create(creator_identifier)
if not hasattr(creator, "product_base_type"):
warn(
f"Provided creator {creator!r} doesn't have "
"product base type attribute defined. This will be "
"required in future.",
DeprecationWarning,
stacklevel=2
)
project_name = self.project_name
if folder_entity is None:
folder_path = self.get_current_folder_path()

View file

@ -405,7 +405,7 @@ class BaseCreator(ABC):
product_name=product_name,
data=data,
creator=self,
product_base_type=product_base_type
product_base_type=product_base_type,
)
self._add_instance_to_context(instance)
return instance
@ -516,7 +516,7 @@ class BaseCreator(ABC):
self,
project_name: str,
folder_entity: dict[str, Any],
task_entity: dict[str, Any],
task_entity: Optional[dict[str, Any]],
variant: str,
host_name: Optional[str] = None,
instance: Optional[CreatedInstance] = None,

View file

@ -82,9 +82,9 @@ def get_product_name_template(
def get_product_name(
project_name: str,
task_name: str,
task_name: Optional[str],
task_type: Optional[str],
host_name: Optional[str],
host_name: str,
product_type: str,
variant: str,
default_template: Optional[str] = None,
@ -180,14 +180,7 @@ def get_product_name(
task_short = task_types_by_name.get(task_type, {}).get("shortName")
task_value["short"] = task_short
# look what we have to do to make mypy happy. We should stop using
# those undefined dict based types.
product: dict[str, str] = {
"type": product_type,
"baseType": product_base_type
}
if not product_base_type and "{product[basetype]}" in template.lower():
product["baseType"] = product_type
warn(
"You have Product base type in product name template, "
"but it is not provided by the creator, please update your "
@ -200,7 +193,10 @@ def get_product_name(
"variant": variant,
"family": product_type,
"task": task_value,
"product": product,
"product": {
"type": product_type,
"baseType": product_base_type or product_type,
}
}
if dynamic_data:

View file

@ -12,7 +12,6 @@ from ayon_core.lib.attribute_definitions import (
deserialize_attr_defs,
)
from ayon_core.pipeline.compatibility import is_product_base_type_supported
from ayon_core.pipeline import (
AYON_INSTANCE_ID,
@ -577,8 +576,7 @@ class CreatedInstance:
self._data["productType"] = product_type
self._data["productName"] = product_name
if is_product_base_type_supported():
self._data["productBaseType"] = product_base_type
self._data["productBaseType"] = product_base_type
self._data["active"] = data.get("active", True)
self._data["creator_identifier"] = creator_identifier