diff --git a/python/lsst/daf/butler/queries/expression_factory.py b/python/lsst/daf/butler/queries/expression_factory.py index b50cf1983e..cc52c5c760 100644 --- a/python/lsst/daf/butler/queries/expression_factory.py +++ b/python/lsst/daf/butler/queries/expression_factory.py @@ -30,7 +30,6 @@ __all__ = ("ExpressionFactory", "ExpressionProxy", "ScalarExpressionProxy", "TimespanProxy", "RegionProxy") from collections.abc import Iterable -from types import EllipsisType from typing import TYPE_CHECKING, get_args from lsst.sphgeom import Region @@ -294,7 +293,7 @@ class DatasetTypeProxy: Parameters ---------- - dataset_type : `str` or ``...`` + dataset_type : `str` Dataset type name or wildcard. Wildcards are usable only when the query contains exactly one dataset type or a wildcard. @@ -304,11 +303,11 @@ class DatasetTypeProxy: associated with datasets rather than their dimensions. """ - def __init__(self, dataset_type: rt.StringOrWildcard): + def __init__(self, dataset_type: str): self._dataset_type = dataset_type def __repr__(self) -> str: - return self._dataset_type if self._dataset_type is not ... else "(...)" + return self._dataset_type # Attributes are actually fixed, but we implement them with __getattr__ # and __dir__ to avoid repeating the list. And someday they might expand @@ -351,7 +350,7 @@ def __getattr__(self, name: str) -> DimensionElementProxy: return DimensionProxy(element) return DimensionElementProxy(element) - def __getitem__(self, name: str | EllipsisType) -> DatasetTypeProxy: + def __getitem__(self, name: str) -> DatasetTypeProxy: return DatasetTypeProxy(name) def not_(self, operand: rt.Predicate) -> rt.Predicate: diff --git a/python/lsst/daf/butler/queries/relation_tree/_base.py b/python/lsst/daf/butler/queries/relation_tree/_base.py index 9ffcf60bbb..5f146a9387 100644 --- a/python/lsst/daf/butler/queries/relation_tree/_base.py +++ b/python/lsst/daf/butler/queries/relation_tree/_base.py @@ -32,14 +32,12 @@ "RootRelationBase", "ColumnExpressionBase", "PredicateBase", - "StringOrWildcard", "DatasetFieldName", "InvalidRelationError", ) from abc import ABC, abstractmethod -from types import EllipsisType -from typing import TYPE_CHECKING, Annotated, Any, Literal, TypeAlias, cast +from typing import TYPE_CHECKING, Any, Literal, TypeAlias, cast import pydantic @@ -52,14 +50,6 @@ from ._relation import Relation, RootRelation -StringOrWildcard = Annotated[ - str | EllipsisType, - pydantic.PlainSerializer(lambda x: "..." if x is ... else x, return_type=str), - pydantic.BeforeValidator(lambda x: ... if x == "..." else x), - pydantic.GetPydanticSchema(lambda _s, h: h(str)), -] - - DatasetFieldName: TypeAlias = Literal["dataset_id", "ingest_date", "run", "collection", "rank", "timespan"] diff --git a/python/lsst/daf/butler/queries/relation_tree/_column_reference.py b/python/lsst/daf/butler/queries/relation_tree/_column_reference.py index c2ffd1d784..b2531f97cd 100644 --- a/python/lsst/daf/butler/queries/relation_tree/_column_reference.py +++ b/python/lsst/daf/butler/queries/relation_tree/_column_reference.py @@ -35,7 +35,7 @@ from ...column_spec import ColumnType from ...dimensions import Dimension, DimensionElement -from ._base import ColumnExpressionBase, DatasetFieldName, InvalidRelationError, StringOrWildcard +from ._base import ColumnExpressionBase, DatasetFieldName, InvalidRelationError @final @@ -121,8 +121,8 @@ class DatasetFieldReference(ColumnExpressionBase): expression_type: Literal["dataset_field"] = "dataset_field" - dataset_type: StringOrWildcard - """Name of the dataset type, or ``...`` to match any dataset type.""" + dataset_type: str + """Name of the dataset type to match any dataset type.""" field: DatasetFieldName """Name of the field (i.e. column) in the dataset's logical table.""" @@ -160,10 +160,7 @@ def column_type(self) -> ColumnType: raise AssertionError(f"Invalid field {self.field!r} for dataset.") def __str__(self) -> str: - if self.dataset_type is ...: - return self.field - else: - return f"{self.dataset_type}.{self.field}" + return f"{self.dataset_type}.{self.field}" # Union without Pydantic annotation for the discriminator, for use in nesting