From e6b35a88efccc223d0a19e30c617b4bde344d2fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=B3pez=20Barr=C3=B3n?= Date: Sat, 21 Dec 2024 07:28:39 +1100 Subject: [PATCH] use abc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian López Barrón --- grill/cook/__init__.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/grill/cook/__init__.py b/grill/cook/__init__.py index 08001b98..ac6ecee3 100644 --- a/grill/cook/__init__.py +++ b/grill/cook/__init__.py @@ -33,9 +33,9 @@ import itertools import contextlib import contextvars -import collections from pathlib import Path from pprint import pformat +from collections import abc import networkx as nx from pxr import UsdGeom, Usd, Sdf, Kind, Ar @@ -129,7 +129,7 @@ def fetch_stage(identifier: typing.Union[str, UsdAsset], context: Ar.ResolverCon return Usd.Stage.Open(layer, load=load) -def define_taxon(stage: Usd.Stage, name: str, *, references: tuple[Usd.Prim] = tuple(), id_fields: collections.abc.Mapping[str, str] = types.MappingProxyType({})) -> Usd.Prim: +def define_taxon(stage: Usd.Stage, name: str, *, references: tuple[Usd.Prim] = tuple(), id_fields: abc.Mapping[str, str] = types.MappingProxyType({})) -> Usd.Prim: """Define a new `taxon group `_ for asset `taxonomy `_. If an existing ``taxon`` with the provided name already exists in the `stage `_, it is used. @@ -172,7 +172,7 @@ def define_taxon(stage: Usd.Stage, name: str, *, references: tuple[Usd.Prim] = t return prim -def itaxa(stage: Usd.Stage) -> collections.abc.Iterator[Usd.Prim]: +def itaxa(stage: Usd.Stage) -> abc.Iterator[Usd.Prim]: """For the given stage, iterate existing taxa under the taxonomy hierarchy.""" return filter( lambda prim: prim.GetAssetInfoByKey(_ASSETINFO_TAXA_KEY), @@ -194,7 +194,7 @@ def _broadcast_root_path(taxon, broadcast_method, scope_path=None): return scope_path.ReplacePrefix(_CATALOGUE_ROOT_PATH, _BROADCAST_METHOD_RELPATHS[broadcast_method]) -def create_many(taxon: Usd.Prim, names: collections.abc.Iterable[str], labels: collections.abc.Iterable[str] = tuple()) -> list[Usd.Prim]: +def create_many(taxon: Usd.Prim, names: abc.Iterable[str], labels: abc.Iterable[str] = tuple()) -> list[Usd.Prim]: """Create a new taxon member for each of the provided names. When creating hundreds or thousands of members, this provides a considerable performance improvement over :func:`create_unit`. @@ -457,12 +457,12 @@ def _root_asset(stage): def _get_id_fields(prim): if not (fields:=prim.GetAssetInfoByKey(_ASSETINFO_FIELDS_KEY)): raise ValueError(f"Missing or empty '{_FIELDS_KEY}' on '{_ASSETINFO_KEY}' asset info for {prim}. Got: {pformat(prim.GetAssetInfoByKey(_ASSETINFO_KEY))}") - if not isinstance(fields, collections.abc.Mapping): + if not isinstance(fields, abc.Mapping): raise TypeError(f"Expected mapping on key '{_FIELDS_KEY}' from {prim} on custom data key '{_ASSETINFO_KEY}'. Got instead {fields} with type: {type(fields)}") return fields -def _find_layer_matching(tokens: collections.abc.Mapping, layers: collections.abc.Iterable[Sdf.Layer]) -> Sdf.Layer: +def _find_layer_matching(tokens: abc.Mapping, layers: abc.Iterable[Sdf.Layer]) -> Sdf.Layer: """Find the first layer matching the given identifier tokens. :raises ValueError: If none of the given layers match the provided tokens.