Skip to content

Commit 9757336

Browse files
committed
use Mapping from collections instead of typing
Signed-off-by: Christian López Barrón <chris.gfz@gmail.com>
1 parent 69830da commit 9757336

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

grill/cook/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
from __future__ import annotations
2626

2727
import types
28+
# https://docs.python.org/3/whatsnew/3.10.html#pep-604-new-type-union-operator
29+
# TODO: Remove when py-3.10+ is supported (for union types)
2830
import typing
2931
import logging
3032
import functools
@@ -127,7 +129,7 @@ def fetch_stage(identifier: typing.Union[str, UsdAsset], context: Ar.ResolverCon
127129
return Usd.Stage.Open(layer, load=load)
128130

129131

130-
def define_taxon(stage: Usd.Stage, name: str, *, references: tuple[Usd.Prim] = tuple(), id_fields: typing.Mapping[str, str] = types.MappingProxyType({})) -> Usd.Prim:
132+
def define_taxon(stage: Usd.Stage, name: str, *, references: tuple[Usd.Prim] = tuple(), id_fields: collections.abc.Mapping[str, str] = types.MappingProxyType({})) -> Usd.Prim:
131133
"""Define a new `taxon group <https://en.wikipedia.org/wiki/Taxon>`_ for asset `taxonomy <https://en.wikipedia.org/wiki/Taxonomy>`_.
132134
133135
If an existing ``taxon`` with the provided name already exists in the `stage <https://graphics.pixar.com/usd/docs/api/class_usd_stage.html>`_, it is used.
@@ -455,12 +457,12 @@ def _root_asset(stage):
455457
def _get_id_fields(prim):
456458
if not (fields:=prim.GetAssetInfoByKey(_ASSETINFO_FIELDS_KEY)):
457459
raise ValueError(f"Missing or empty '{_FIELDS_KEY}' on '{_ASSETINFO_KEY}' asset info for {prim}. Got: {pformat(prim.GetAssetInfoByKey(_ASSETINFO_KEY))}")
458-
if not isinstance(fields, typing.Mapping):
460+
if not isinstance(fields, collections.abc.Mapping):
459461
raise TypeError(f"Expected mapping on key '{_FIELDS_KEY}' from {prim} on custom data key '{_ASSETINFO_KEY}'. Got instead {fields} with type: {type(fields)}")
460462
return fields
461463

462464

463-
def _find_layer_matching(tokens: typing.Mapping, layers: collections.abc.Iterable[Sdf.Layer]) -> Sdf.Layer:
465+
def _find_layer_matching(tokens: collections.abc.Mapping, layers: collections.abc.Iterable[Sdf.Layer]) -> Sdf.Layer:
464466
"""Find the first layer matching the given identifier tokens.
465467
466468
:raises ValueError: If none of the given layers match the provided tokens.

grill/usd/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Helpers for USD workflows which do not know anything about the pipeline."""
22
import enum
3+
# https://docs.python.org/3/whatsnew/3.10.html#pep-604-new-type-union-operator
4+
# TODO: Remove when py-3.10+ is supported (for union types)
35
import typing
46
import inspect
57
import logging
@@ -305,7 +307,7 @@ def is_target(arc):
305307

306308

307309
@contextlib.contextmanager
308-
def _prim_tree_printer(predicate, prims_to_include: typing.Container = frozenset()):
310+
def _prim_tree_printer(predicate, prims_to_include: abc.Container = frozenset()):
309311
prim_entry = Usd.Prim.GetName if predicate != Usd.PrimIsModel else lambda prim: f"{prim.GetName()} ({Usd.ModelAPI(prim).GetKind()})"
310312

311313
class PrimTreePrinter(TreePrinter):

0 commit comments

Comments
 (0)