diff --git a/src/globus_sdk/scopes/_graph_parser.py b/src/globus_sdk/scopes/_graph_parser.py index 1718e0b73..9e7e7b649 100644 --- a/src/globus_sdk/scopes/_graph_parser.py +++ b/src/globus_sdk/scopes/_graph_parser.py @@ -113,7 +113,7 @@ def _convert_trees(cls, trees: list[ScopeTreeNode]) -> ScopeGraph: _add_dataclass_kwargs: dict[str, bool] = {} -@dataclasses.dataclass(**_add_dataclass_kwargs) +@dataclasses.dataclass(repr=False, eq=False, order=False, **_add_dataclass_kwargs) class ScopeTreeNode: # # This is an intermediate representation for scope parsing. diff --git a/src/globus_sdk/scopes/representation.py b/src/globus_sdk/scopes/representation.py index bb031ad82..5e215f23c 100644 --- a/src/globus_sdk/scopes/representation.py +++ b/src/globus_sdk/scopes/representation.py @@ -1,6 +1,7 @@ from __future__ import annotations import dataclasses +import re import sys import typing as t @@ -12,6 +13,9 @@ _add_dataclass_kwargs: dict[str, bool] = {} +_BAD_SCOPE_CHARS_PATTERN: re.Pattern[str] = re.compile(r"[\[\]* ]") + + @dataclasses.dataclass(frozen=True, repr=False, **_add_dataclass_kwargs) class Scope: """ @@ -40,7 +44,7 @@ class Scope: def __post_init__( self, ) -> None: - if any(c in self.scope_string for c in "[]* "): + if _BAD_SCOPE_CHARS_PATTERN.search(self.scope_string): raise ValueError( "Scope instances may not contain the special characters '[]* '. " "Use Scope.parse instead."