Skip to content

Commit

Permalink
Internal changes.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 545066179
  • Loading branch information
PyGlove Authors committed Jul 2, 2023
1 parent 9b2bd3b commit 769c936
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
11 changes: 7 additions & 4 deletions pyglove/core/symbolic/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,8 +669,10 @@ def sym_rebind(
Callable]] = None, # pylint: disable=g-bare-generic
raise_on_no_change: bool = True,
skip_notification: Optional[bool] = None,
**kwargs) -> 'Symbolic':
**kwargs,
) -> 'Symbolic':
"""Mutates the sub-nodes of current object. Please see `rebind`."""
assert Symbolic.DictType is not None
if callable(path_value_pairs):
path_value_pairs = get_rebind_dict(path_value_pairs, self)
elif path_value_pairs is None:
Expand Down Expand Up @@ -2130,6 +2132,7 @@ class A(pg.Object):
* symbolic.Object for dict with '_type' property.
* value itself.
"""
assert Symbolic.DictType is not None
if isinstance(json_value, Symbolic):
return json_value

Expand All @@ -2151,7 +2154,7 @@ class A(pg.Object):
root_path=object_utils.KeyPath(i, root_path))
for i, v in enumerate(json_value[1:])
])
return Symbolic.ListType(json_value, **kwargs) # pylint: disable=not-callable
return Symbolic.ListType(json_value, **kwargs) # pytype: disable=not-callable # pylint: disable=not-callable
elif isinstance(json_value, dict):
if object_utils.JSONConvertible.TYPE_NAME_KEY not in json_value:
return Symbolic.DictType.from_json(json_value, **kwargs)
Expand Down Expand Up @@ -2394,7 +2397,7 @@ def _fn(
if isinstance(value, dict):
value_spec = pg_typing.ensure_value_spec(
field.value, pg_typing.Dict(), path)
value = Symbolic.DictType( # pylint: disable=not-callable
value = Symbolic.DictType( # pytype: disable=not-callable # pylint: disable=not-callable
value,
value_spec=value_spec,
allow_partial=allow_partial,
Expand All @@ -2407,7 +2410,7 @@ def _fn(
elif isinstance(value, list):
value_spec = pg_typing.ensure_value_spec(
field.value, pg_typing.List(pg_typing.Any()), path)
value = Symbolic.ListType( # pylint: disable=not-callable
value = Symbolic.ListType( # pytype: disable=not-callable # pylint: disable=not-callable
value,
value_spec=value_spec,
allow_partial=allow_partial,
Expand Down
6 changes: 3 additions & 3 deletions pyglove/core/symbolic/dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ def sym_keys(self) -> Iterator[str]:
yield key
else:
traversed = set()
for key_spec in self._value_spec.schema.keys():
for key_spec in self._value_spec.schema.keys(): # pytype: disable=attribute-error
if isinstance(key_spec, pg_typing.ConstStrKey) and key_spec in self:
yield key_spec.text
traversed.add(key_spec.text)
Expand Down Expand Up @@ -780,7 +780,7 @@ def sym_jsonify(
exclude_keys = set(exclude_keys or [])
if self._value_spec and self._value_spec.schema:
json_repr = dict()
matched_keys, _ = self._value_spec.schema.resolve(self.keys())
matched_keys, _ = self._value_spec.schema.resolve(self.keys()) # pytype: disable=attribute-error
for key_spec, keys in matched_keys.items():
# NOTE(daiyip): The key values of frozen field can safely be excluded
# since they will be the same for a class.
Expand Down Expand Up @@ -861,7 +861,7 @@ def _indent(text, indent):

field_list = []
if self._value_spec and self._value_spec.schema:
matched_keys, unmatched = self._value_spec.schema.resolve(self.keys())
matched_keys, unmatched = self._value_spec.schema.resolve(self.keys()) # pytype: disable=attribute-error
assert not unmatched
for key_spec, keys in matched_keys.items():
for key in keys:
Expand Down
4 changes: 2 additions & 2 deletions pyglove/core/typing/class_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ def get_field(self, key: str) -> Optional[Field]:
return None

@property
def description(self) -> str:
def description(self) -> Optional[str]:
"""Returns the description for the schema."""
return self._description

Expand Down Expand Up @@ -1126,7 +1126,7 @@ def validate(self,
root_path=root_path)

@property
def name(self) -> str:
def name(self) -> Optional[str]:
"""Name of this schema."""
return self._name

Expand Down
2 changes: 1 addition & 1 deletion pyglove/core/typing/value_specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ def min_value(self) -> typing.Optional[numbers.Number]:
return self._min_value

@property
def max_value(self) -> numbers.Number:
def max_value(self) -> typing.Optional[numbers.Number]:
"""Returns maximum value of acceptable values."""
return self._max_value

Expand Down

0 comments on commit 769c936

Please sign in to comment.