diff --git a/assets/src/data/scripts/bafoundation/entity/_entity.py b/assets/src/data/scripts/bafoundation/entity/_entity.py index e7f54698..014e5e60 100644 --- a/assets/src/data/scripts/bafoundation/entity/_entity.py +++ b/assets/src/data/scripts/bafoundation/entity/_entity.py @@ -138,6 +138,8 @@ class EntityMixin: This uses bafoundation.jsontools.ExtendedJSONEncoder/Decoder to support data types not natively storable in json. + Be sure to use the corresponding loading functions here for + this same reason. """ if prune: data = self.pruned_data() diff --git a/docs/ba_module.md b/docs/ba_module.md index af51e5b5..a7f47852 100644 --- a/docs/ba_module.md +++ b/docs/ba_module.md @@ -1,6 +1,6 @@ - -

last updated on 2020-01-04 for Ballistica version 1.5.0 build 20001

+ +

last updated on 2020-01-17 for Ballistica version 1.5.0 build 20001

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 let me know. Happy modding!


diff --git a/tools/efrotools/pybuild.py b/tools/efrotools/pybuild.py index 6c91ef60..50dc8e48 100644 --- a/tools/efrotools/pybuild.py +++ b/tools/efrotools/pybuild.py @@ -47,8 +47,8 @@ def build_apple(arch: str, debug: bool = False) -> None: os.chdir(builddir) # TEMP: Check out a particular commit while the branch head is broken. - # efrotools.run('git checkout 1a9c71dca298c03517e8236b81cf1d9c8c521cbf') - efrotools.run(f'git checkout {PYTHON_VERSION_MAJOR}') + efrotools.run('git checkout 1a9c71dca298c03517e8236b81cf1d9c8c521cbf') + # efrotools.run(f'git checkout {PYTHON_VERSION_MAJOR}') # On mac we currently have to add the _scproxy module or urllib will # fail. @@ -267,14 +267,13 @@ def build_android(rootdir: str, arch: str, debug: bool = False) -> None: "super().__init__('https://github.com/python/cpython/', branch='3.7')") # Turn ipv6 on (curious why its turned off here?...) + # Also, turn on low level debugging features for our debug builds. ftxt = efrotools.replace_one(ftxt, "'--disable-ipv6',", "'--enable-ipv6',") if debug: ftxt = efrotools.replace_one(ftxt, "'./configure',", "'./configure', '--with-pydebug',") # We don't use this stuff so lets strip it out to simplify. - # ftxt = efrotools.replace_one(ftxt, "'--with-system-ffi',", "") - # ftxt = efrotools.replace_one(ftxt, "'--with-system-expat',", "") ftxt = efrotools.replace_one(ftxt, "'--without-ensurepip',", "") # This builds all modules as dynamic libs, but we want to be consistent @@ -287,18 +286,10 @@ def build_android(rootdir: str, arch: str, debug: bool = False) -> None: ' if os.system(\'"' + rootdir + '/tools/snippets" python_android_patch "' + os.getcwd() + '"\') != 0: raise Exception("patch apply failed")') - # ftxt = efrotools.replace_one( - # ftxt, ' def prepare(self):', - # ' def prepare(self):\n import os\n' - # ' if os.system(\'"' + rootdir + - # '/tools/snippets" python_android_patch "' + os.getcwd() + - # '"\') != 0: raise Exception("patch apply failed")') efrotools.writefile('pybuild/packages/python.py', ftxt) # Set this to a particular cpython commit to target exact releases from git - # commit = 'e09359112e250268eca209355abeb17abf822486' # 3.7.4 release - # commit = '5c02a39a0b31a330e06b4d6f44835afb205dc7cc' # 3.7.5 release commit = '43364a7ae01fbe4288ef42622259a0038ce1edcc' # 3.7.6 release if commit is not None: diff --git a/tools/efrotools/pylintplugins.py b/tools/efrotools/pylintplugins.py index 85b82f2d..ad8a04ca 100644 --- a/tools/efrotools/pylintplugins.py +++ b/tools/efrotools/pylintplugins.py @@ -80,6 +80,22 @@ def ignore_type_check_filter(node: nc.NodeNG) -> nc.NodeNG: return node +def ignore_reveal_type_call(node: nc.NodeNG) -> nc.NodeNG: + """Make 'reveal_type()' not trigger an error. + + The 'reveal_type()' fake call is used for type debugging types with + mypy and it is annoying having pylint errors pop up alongside the mypy + info. + """ + + # Let's just replace any reveal_type(x) call with print(x).. + if (isinstance(node.func, astroid.Name) + and node.func.name == 'reveal_type'): + node.func.name = 'print' + return node + return node + + def _strip_import(cnode: nc.NodeNG, mnode: nc.NodeNG) -> None: if isinstance(cnode, (astroid.Import, astroid.ImportFrom)): for name, val in list(mnode.locals.items()): @@ -194,6 +210,8 @@ def register_plugins(manager: astroid.Manager) -> None: # check code as if it doesn't exist at all. manager.register_transform(astroid.If, ignore_type_check_filter) + manager.register_transform(astroid.Call, ignore_reveal_type_call) + # Annotations on variables within a function are defer-eval'ed # in some cases, so lets replace them with simple strings in those # cases to avoid type complaints.