mirror of
https://github.com/RYDE-WORK/ballistica.git
synced 2026-01-28 10:03:15 +08:00
lint and lang updates
This commit is contained in:
parent
5382fe1c5f
commit
67649a0eae
@ -420,7 +420,7 @@
|
||||
"assets/build/ba_data/audio/zoeOw.ogg": "https://files.ballistica.net/cache/ba1/41/a0/d7edfdeada25eb8310de177ab7f5",
|
||||
"assets/build/ba_data/audio/zoePickup01.ogg": "https://files.ballistica.net/cache/ba1/15/ba/7db3f4534699517b8bff3ffae4b6",
|
||||
"assets/build/ba_data/audio/zoeScream01.ogg": "https://files.ballistica.net/cache/ba1/6d/de/d973377a4f5f975470f958119b0b",
|
||||
"assets/build/ba_data/data/langdata.json": "https://files.ballistica.net/cache/ba1/c7/34/1a9fa903adfbde472a0a7e97cc4b",
|
||||
"assets/build/ba_data/data/langdata.json": "https://files.ballistica.net/cache/ba1/57/ae/9ea5a3e00bdf3a3caf76e67a577c",
|
||||
"assets/build/ba_data/data/languages/arabic.json": "https://files.ballistica.net/cache/ba1/68/6d/7a251c216dda7550ca871871e2d1",
|
||||
"assets/build/ba_data/data/languages/belarussian.json": "https://files.ballistica.net/cache/ba1/55/8c/8d0a0585e434b94865ae4befc090",
|
||||
"assets/build/ba_data/data/languages/chinese.json": "https://files.ballistica.net/cache/ba1/29/0a/2a796246ae05dbf316a3551b8970",
|
||||
@ -450,7 +450,7 @@
|
||||
"assets/build/ba_data/data/languages/spanish.json": "https://files.ballistica.net/cache/ba1/66/9e/df12c6325c503f8eaef4a83259c4",
|
||||
"assets/build/ba_data/data/languages/swedish.json": "https://files.ballistica.net/cache/ba1/50/9f/be006ba19be6a69a57837eb6dca0",
|
||||
"assets/build/ba_data/data/languages/tamil.json": "https://files.ballistica.net/cache/ba1/31/b0/957a09affb9ea8e0fefb1d447a6e",
|
||||
"assets/build/ba_data/data/languages/thai.json": "https://files.ballistica.net/cache/ba1/dd/de/c197fa9aff42e4422bc66b95ad88",
|
||||
"assets/build/ba_data/data/languages/thai.json": "https://files.ballistica.net/cache/ba1/74/3d/c3d40a1e5ee1edf82555da05eda9",
|
||||
"assets/build/ba_data/data/languages/turkish.json": "https://files.ballistica.net/cache/ba1/65/e4/b9308f15437972209b4d3fce7abd",
|
||||
"assets/build/ba_data/data/languages/ukrainian.json": "https://files.ballistica.net/cache/ba1/8f/42/56f3ebcc6005f382449c1c2422fd",
|
||||
"assets/build/ba_data/data/languages/venetian.json": "https://files.ballistica.net/cache/ba1/ff/a7/d74151ee6fa1d228cafb52e52f04",
|
||||
@ -3966,50 +3966,50 @@
|
||||
"assets/src/ba_data/python/ba/_generated/__init__.py": "https://files.ballistica.net/cache/ba1/ee/e8/cad05aa531c7faf7ff7b96db7f6e",
|
||||
"assets/src/ba_data/python/ba/_generated/enums.py": "https://files.ballistica.net/cache/ba1/72/82/86956fae909ac2fe2a1abd84a361",
|
||||
"ballisticacore-windows/Generic/BallisticaCore.ico": "https://files.ballistica.net/cache/ba1/89/c0/e32c7d2a35dc9aef57cc73b0911a",
|
||||
"build/prefab/full/linux_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/5a/43/31f1e7a1f06ff634e853b2fe478b",
|
||||
"build/prefab/full/linux_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/e0/06/60b8a1d7a19049a169c2b68cf89e",
|
||||
"build/prefab/full/linux_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/74/1d/fc9e33e565475daaac80da5252f0",
|
||||
"build/prefab/full/linux_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/a1/2b/84b86a21eaa2622439ddf96a879e",
|
||||
"build/prefab/full/linux_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/fb/ba/c6f4160413f84da9fc199eba8906",
|
||||
"build/prefab/full/linux_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/2d/6e/32e40af876d49a80c3cda22395ee",
|
||||
"build/prefab/full/linux_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/ff/56/a8f14d13ba81f23800568720624d",
|
||||
"build/prefab/full/linux_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/39/11/72a9a331f96f4bca715374dbf242",
|
||||
"build/prefab/full/linux_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/00/a8/92d6a00c4af3c43e0af4bbe7b143",
|
||||
"build/prefab/full/linux_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/9c/7b/ac1a200be0f37078af0991faca3b",
|
||||
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/03/c5/dcd0c09e5b0020923459abc08d76",
|
||||
"build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/52/61/4ee73c405443f6807611f0ab4d65",
|
||||
"build/prefab/full/mac_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/bd/25/4532f4fec61de6c5d3c0dc3e37dd",
|
||||
"build/prefab/full/mac_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/af/4d/3d6f711c2b06ac774609bdb563b0",
|
||||
"build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/8b/7a/35d194e46cf4329d2da83de82f21",
|
||||
"build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/44/4f/c7f841bc873cf278c25dd983c97c",
|
||||
"build/prefab/full/mac_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/67/d7/97716594f45bdbee32f45d6416bd",
|
||||
"build/prefab/full/mac_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/63/5f/3e20ac2d36d2c1746fe5a1b57759",
|
||||
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/5c/60/946f24032d0a9981663bc26bf1e4",
|
||||
"build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/4c/17/6afb195ab8ec46b8ed76b940d2ed",
|
||||
"build/prefab/full/windows_x86_gui/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/4f/59/4e0f38c6ca7b876e121c4e911dc7",
|
||||
"build/prefab/full/windows_x86_gui/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/2d/66/c1d56619c94d1203b4a7a73959a0",
|
||||
"build/prefab/full/windows_x86_server/debug/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/71/98/e4589dd1fd33c8483281a72d5ef5",
|
||||
"build/prefab/full/windows_x86_server/release/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/ac/46/d501ee43d3204887092560d25de0",
|
||||
"build/prefab/lib/linux_arm64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/5f/7c/427e8a1af1c95bf40211adb1a10e",
|
||||
"build/prefab/lib/linux_arm64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/5e/fe/0366d7ace626419f14c2bd80e266",
|
||||
"build/prefab/lib/linux_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/9b/2c/7be9dce2d9aff8cf04508d07dff0",
|
||||
"build/prefab/lib/linux_arm64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/0e/c3/b9d0325bee5ee116a1311a87dd11",
|
||||
"build/prefab/lib/linux_x86_64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/8b/ff/1345a0a9d07ea8b7164ec2a97234",
|
||||
"build/prefab/lib/linux_x86_64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/d7/2c/9fa96710e25f6242c42ff3efd309",
|
||||
"build/prefab/lib/linux_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/89/45/43b51cddf1b4655d31018158b344",
|
||||
"build/prefab/lib/linux_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/8c/6d/c3f165109101ae65f3ecbc556492",
|
||||
"build/prefab/lib/mac_arm64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/1a/12/fd3382e3ae5c5810b00a988540ec",
|
||||
"build/prefab/lib/mac_arm64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/b7/5d/bd55990fe03531e438000d5f0aab",
|
||||
"build/prefab/lib/mac_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/6b/9b/0a5965e1714cdda72a9a0417ff04",
|
||||
"build/prefab/lib/mac_arm64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/ed/f6/c40b675afed682fc96684228dd37",
|
||||
"build/prefab/lib/mac_x86_64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/9f/1e/41254c471d95083243bd146e35ae",
|
||||
"build/prefab/lib/mac_x86_64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/cf/68/90f68e1e6d2fd75c340dfc85f982",
|
||||
"build/prefab/lib/mac_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/6d/c6/e4f93048d8dbcfb7f451aeacd2c9",
|
||||
"build/prefab/lib/mac_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/08/bf/9e91d76ff229a92ed10cedbf8cb1",
|
||||
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/66/5f/b8abc6d993bb5296fc63853b21ce",
|
||||
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/2a/5b/dd04558a02272cb7e407bca63da7",
|
||||
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/37/1e/a81e165c91ddf8d8c6fe8e3f57f1",
|
||||
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/17/1b/c80441a942276010b6996b45df29",
|
||||
"build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/61/c8/3e2b5ed912cc252886b56445d1ad",
|
||||
"build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/67/c7/05b1673224fe473d83a03ec62a18",
|
||||
"build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/39/2e/30137404ba9e1504fc856a95594c",
|
||||
"build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/13/0b/d55b28a1c60c55d34739185cc8ba",
|
||||
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/1a/83/3884b71fc3c83a597114c661fc94",
|
||||
"build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/be/98/c29dc5249a7d772f778de4ca4119",
|
||||
"build/prefab/full/mac_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/c8/2f/07bae56da30dd2a4eb549d21788a",
|
||||
"build/prefab/full/mac_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/7d/fd/cf88baa3715276b66ffc8e500c28",
|
||||
"build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/cd/86/75a814002acbd4e3e7ce72135a69",
|
||||
"build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/e5/9a/90efe486fbe7015fc45d71215350",
|
||||
"build/prefab/full/mac_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/34/81/45129983739ba3ab4c3b42aa6039",
|
||||
"build/prefab/full/mac_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/5e/10/d0a79286b205c0da36f0a05b289c",
|
||||
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/20/9e/2798a0a74cf535e1cccb4e2feb00",
|
||||
"build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/95/55/eefd6a0c57c7a1f5d84128d3c1de",
|
||||
"build/prefab/full/windows_x86_gui/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/f2/9f/d5b12184218d6f15743d22e34ecf",
|
||||
"build/prefab/full/windows_x86_gui/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/34/b9/0da9f3ac3d89cf144130ed5d6032",
|
||||
"build/prefab/full/windows_x86_server/debug/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/bb/a3/8ee9ae4cd5260306bb14a17792ea",
|
||||
"build/prefab/full/windows_x86_server/release/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/79/79/5b30b573a258262cf7ab5247b05d",
|
||||
"build/prefab/lib/linux_arm64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/a3/d7/80ac73303ca83f1768b9ce1c2078",
|
||||
"build/prefab/lib/linux_arm64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/f5/2a/c618f4f733d32d8a583348042e20",
|
||||
"build/prefab/lib/linux_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/63/6a/d187d352844a3b7c1861e79d2c8f",
|
||||
"build/prefab/lib/linux_arm64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/bb/52/ae0ed2e83a449865252d90c2ac9a",
|
||||
"build/prefab/lib/linux_x86_64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/be/2e/4bc4bf1ec4db1b98c7d7081095d4",
|
||||
"build/prefab/lib/linux_x86_64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/59/7e/253051aa3d105e94235f74a0b5ae",
|
||||
"build/prefab/lib/linux_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/d3/65/63cf06b0f8bd7fbc15edaf8a842b",
|
||||
"build/prefab/lib/linux_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/63/61/7ff8074fa76ae8b5010b07d4f1f2",
|
||||
"build/prefab/lib/mac_arm64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/5a/31/9b542804ba449ce4c8c6eddf3971",
|
||||
"build/prefab/lib/mac_arm64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/3c/38/6be5cd846d6bd38acea70e8ee667",
|
||||
"build/prefab/lib/mac_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/2b/d9/7c24f63dd8737ca4ecb77d103560",
|
||||
"build/prefab/lib/mac_arm64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/70/2c/1d44685db575e201542685f41f32",
|
||||
"build/prefab/lib/mac_x86_64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/82/97/2afbffeaf0989dfd5094a48ecac7",
|
||||
"build/prefab/lib/mac_x86_64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/d4/2c/d5cdded5a9d1018dad9f8e8a812e",
|
||||
"build/prefab/lib/mac_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/ac/47/16da91f514af302c5435d060d75c",
|
||||
"build/prefab/lib/mac_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/67/5b/47db352ef527391482b42e1072e8",
|
||||
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/9f/1d/3d2c2056c491fdab1055a6a5f114",
|
||||
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/1e/a2/ff5dd453f396fa58362e24b34b5f",
|
||||
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/30/8b/3a547ac0ce167a0c43492dab5104",
|
||||
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/73/8d/d25e325791ac3e0aab48f204bea3",
|
||||
"build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/cd/a4/925f8c8ef4026b07b55ef841e8e8",
|
||||
"build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/62/b9/3539b66b55f11851633a120b40a1",
|
||||
"build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/64/d6/57d647611e82b6b36b0c2decd826",
|
||||
"build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/f7/2f/f34dd67c2d40a8988b999cb59d2e",
|
||||
"src/ballistica/generated/python_embedded/binding.inc": "https://files.ballistica.net/cache/ba1/f2/6c/5a0a4695dcc2a11e7941b8777e80",
|
||||
"src/ballistica/generated/python_embedded/bootstrap.inc": "https://files.ballistica.net/cache/ba1/65/ac/d5c4162a71028c1bfa73ebc1f881"
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
<!-- THIS FILE IS AUTO GENERATED; DO NOT EDIT BY HAND -->
|
||||
<h4><em>last updated on 2021-12-17 for Ballistica version 1.6.6 build 20414</em></h4>
|
||||
<h4><em>last updated on 2021-12-22 for Ballistica version 1.6.6 build 20416</em></h4>
|
||||
<p>This page documents the Python classes and functions in the 'ba' module,
|
||||
which are the ones most relevant to modding in Ballistica. If you come across something you feel should be included here or could be better explained, please <a href="mailto:support@froemling.net">let me know</a>. Happy modding!</p>
|
||||
<hr>
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
namespace ballistica {
|
||||
|
||||
// These are set automatically via script; don't modify them here.
|
||||
const int kAppBuildNumber = 20414;
|
||||
const int kAppBuildNumber = 20416;
|
||||
const char* kAppVersion = "1.6.6";
|
||||
|
||||
// Our standalone globals.
|
||||
|
||||
@ -32,7 +32,7 @@ class PipRequirement:
|
||||
# entries; this accounts for manual installations or other nonstandard setups.
|
||||
PIP_REQUIREMENTS = [
|
||||
PipRequirement(modulename='pylint', minversion=[2, 12, 1]),
|
||||
PipRequirement(modulename='mypy', minversion=[0, 920]),
|
||||
PipRequirement(modulename='mypy', minversion=[0, 930]),
|
||||
PipRequirement(modulename='yapf', minversion=[0, 31, 0]),
|
||||
PipRequirement(modulename='cpplint', minversion=[1, 5, 5]),
|
||||
PipRequirement(modulename='pytest', minversion=[6, 2, 4]),
|
||||
|
||||
@ -10,6 +10,7 @@ data formats in a nondestructive manner.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from enum import Enum
|
||||
from typing import TYPE_CHECKING, TypeVar
|
||||
|
||||
from efro.dataclassio._outputter import _Outputter
|
||||
@ -19,7 +20,7 @@ from efro.dataclassio._prep import ioprep, ioprepped, is_ioprepped_dataclass
|
||||
from efro.dataclassio._pathcapture import DataclassFieldLookup
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Any
|
||||
from typing import Any, Optional
|
||||
|
||||
__all__ = [
|
||||
'Codec', 'IOAttrs', 'ioprep', 'ioprepped', 'is_ioprepped_dataclass',
|
||||
@ -30,6 +31,22 @@ __all__ = [
|
||||
T = TypeVar('T')
|
||||
|
||||
|
||||
class JsonStyle(Enum):
|
||||
"""Different style types for json."""
|
||||
|
||||
# Single line, no spaces, no sorting. Not deterministic.
|
||||
# Use this for most storage purposes.
|
||||
FAST = 'fast'
|
||||
|
||||
# Single line, no spaces, sorted keys. Deterministic.
|
||||
# Use this when output may be hashed or compared for equality.
|
||||
SORTED = 'sorted'
|
||||
|
||||
# Multiple lines, spaces, sorted keys. Deterministic.
|
||||
# Use this for pretty human readable output.
|
||||
PRETTY = 'pretty'
|
||||
|
||||
|
||||
def dataclass_to_dict(obj: Any,
|
||||
codec: Codec = Codec.JSON,
|
||||
coerce_to_float: bool = True) -> dict:
|
||||
@ -59,18 +76,23 @@ def dataclass_to_dict(obj: Any,
|
||||
|
||||
def dataclass_to_json(obj: Any,
|
||||
coerce_to_float: bool = True,
|
||||
pretty: bool = False) -> str:
|
||||
pretty: bool = False,
|
||||
sort_keys: Optional[bool] = None) -> str:
|
||||
"""Utility function; return a json string from a dataclass instance.
|
||||
|
||||
Basically json.dumps(dataclass_to_dict(...)).
|
||||
By default, keys are sorted for pretty output and not otherwise, but
|
||||
this can be overridden by supplying a value for the 'sort_keys' arg.
|
||||
"""
|
||||
import json
|
||||
jdict = dataclass_to_dict(obj=obj,
|
||||
coerce_to_float=coerce_to_float,
|
||||
codec=Codec.JSON)
|
||||
if sort_keys is None:
|
||||
sort_keys = pretty
|
||||
if pretty:
|
||||
return json.dumps(jdict, indent=2, sort_keys=True)
|
||||
return json.dumps(jdict, separators=(',', ':'))
|
||||
return json.dumps(jdict, indent=2, sort_keys=sort_keys)
|
||||
return json.dumps(jdict, separators=(',', ':'), sort_keys=sort_keys)
|
||||
|
||||
|
||||
def dataclass_from_dict(cls: type[T],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user