mirror of
https://github.com/imayushsaini/Bombsquad-Ballistica-Modded-Server.git
synced 2026-08-29 13:16:28 +00:00
ba_data update
This commit is contained in:
parent
2174ae566d
commit
7ba24ecbcf
146 changed files with 1756 additions and 347 deletions
|
|
@ -70,6 +70,13 @@ class IOExtendedData:
|
|||
Can be overridden to migrate old data formats to new, etc.
|
||||
"""
|
||||
|
||||
def did_input(self) -> None:
|
||||
"""Called on a class instance after created from data.
|
||||
|
||||
Can be useful to correct values from the db, etc. in the
|
||||
type-safe form.
|
||||
"""
|
||||
|
||||
|
||||
def _is_valid_for_codec(obj: Any, codec: Codec) -> bool:
|
||||
"""Return whether a value consists solely of json-supported types.
|
||||
|
|
|
|||
|
|
@ -64,11 +64,23 @@ class _Inputter(Generic[T]):
|
|||
|
||||
# For special extended data types, call their 'will_output' callback.
|
||||
tcls = self._cls
|
||||
|
||||
if issubclass(tcls, IOExtendedData):
|
||||
is_ext = True
|
||||
tcls.will_input(values)
|
||||
else:
|
||||
is_ext = False
|
||||
|
||||
out = self._dataclass_from_input(self._cls, '', values)
|
||||
assert isinstance(out, self._cls)
|
||||
|
||||
if is_ext:
|
||||
# mypy complains that we're no longer returning a T
|
||||
# if we operate on out directly.
|
||||
out2 = out
|
||||
assert isinstance(out2, IOExtendedData)
|
||||
out2.did_input()
|
||||
|
||||
return out
|
||||
|
||||
def _value_from_input(
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ from __future__ import annotations
|
|||
import dataclasses
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from typing_extensions import override
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Any
|
||||
|
||||
|
|
@ -32,6 +34,7 @@ class DataclassDiff:
|
|||
self._obj1 = obj1
|
||||
self._obj2 = obj2
|
||||
|
||||
@override
|
||||
def __repr__(self) -> str:
|
||||
return dataclass_diff(self._obj1, self._obj2)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue