Auto formatting updates

This commit is contained in:
Eric Froemling 2020-04-25 12:46:51 -07:00
parent e4a32953db
commit f4e7354b0b
29 changed files with 120 additions and 130 deletions

View File

@ -35,10 +35,10 @@ class AppDelegate:
"""
def create_default_game_config_ui(
self, gameclass: Type[ba.GameActivity], sessionclass: Type[ba.Session],
config: Optional[Dict[str, Any]],
completion_call: Callable[[Optional[Dict[str, Any]]], None]
) -> None:
self, gameclass: Type[ba.GameActivity],
sessionclass: Type[ba.Session], config: Optional[Dict[str, Any]],
completion_call: Callable[[Optional[Dict[str, Any]]],
None]) -> None:
"""Launch a UI to configure the given game config.
It should manipulate the contents of config and call completion_call

View File

@ -71,10 +71,10 @@ class AssetManager:
logging.warning('AssetManager dying in a started state.')
def launch_gather(
self,
packages: List[str],
flavor: AssetPackageFlavor,
account_token: str,
self,
packages: List[str],
flavor: AssetPackageFlavor,
account_token: str,
) -> AssetGather:
"""Spawn an asset-gather operation from this manager."""
print('would gather', packages, 'and flavor', flavor, 'with token',

View File

@ -49,8 +49,10 @@ class GameActivity(Activity):
@classmethod
def create_config_ui(
cls, sessionclass: Type[ba.Session], config: Optional[Dict[str, Any]],
completion_call: Callable[[Optional[Dict[str, Any]]], None]
cls,
sessionclass: Type[ba.Session],
config: Optional[Dict[str, Any]],
completion_call: Callable[[Optional[Dict[str, Any]]], None],
) -> None:
"""Launch an in-game UI to configure settings for a game type.

View File

@ -223,9 +223,8 @@ def get_device_value(device: ba.InputDevice, name: str) -> Any:
'triggerRun2': 6,
'buttonIgnored': 11
}.get(name, -1)
if (devicename in [
'Logitech Dual Action', 'Logitech Cordless RumblePad 2'
]):
if (devicename
in ['Logitech Dual Action', 'Logitech Cordless RumblePad 2']):
return {
'buttonJump': 2,
'buttonPunch': 1,

View File

@ -268,9 +268,9 @@ class Chooser:
# Cycle through our non-random profiles once; after
# that, everyone gets random.
while (app.lobby_random_profile_index <
len(profilenames) and
profilenames[app.lobby_random_profile_index] in
('_random', '__account__', '_edit')):
len(profilenames)
and profilenames[app.lobby_random_profile_index]
in ('_random', '__account__', '_edit')):
app.lobby_random_profile_index += 1
if (app.lobby_random_profile_index <
len(profilenames)):

View File

@ -167,9 +167,8 @@ class MusicController:
# out than later).
try:
cfg = _ba.app.config
if ('Soundtrack' in cfg and cfg['Soundtrack'] not in [
'__default__', 'Default Soundtrack'
]):
if ('Soundtrack' in cfg and cfg['Soundtrack']
not in ['__default__', 'Default Soundtrack']):
self.get_music_player()
except Exception:
from ba import _error

View File

@ -238,8 +238,8 @@ class ServerController:
_ba.pushcall(self.launch_server_session)
def _on_playlist_fetch_response(
self,
result: Optional[Dict[str, Any]],
self,
result: Optional[Dict[str, Any]],
) -> None:
if result is None:
print('Error fetching playlist;' ' aborting.')

View File

@ -386,9 +386,8 @@ class CoopScoreScreen(ba.Activity):
size=(350, 62),
label=ba.Lstr(resource='tournamentStandingsText')
if self.session.tournament_id is not None else ba.Lstr(
resource='worldsBestScoresText')
if self._score_type == 'points' else ba.Lstr(
resource='worldsBestTimesText'),
resource='worldsBestScoresText') if self._score_type
== 'points' else ba.Lstr(resource='worldsBestTimesText'),
autoselect=True,
on_activate_call=ba.WeakCall(self._ui_worlds_best),
transition_delay=delay + 1.9,
@ -728,9 +727,8 @@ class CoopScoreScreen(ba.Activity):
v_offs = 40
txt = Text(ba.Lstr(resource='tournamentStandingsText')
if self.session.tournament_id is not None else ba.Lstr(
resource='worldsBestScoresText')
if self._score_type == 'points' else ba.Lstr(
resource='worldsBestTimesText'),
resource='worldsBestScoresText') if self._score_type
== 'points' else ba.Lstr(resource='worldsBestTimesText'),
maxwidth=210,
position=(ts_h_offs - 10, ts_height / 2 + 25 + v_offs + 20),
transition=Text.Transition.IN_LEFT,
@ -765,9 +763,8 @@ class CoopScoreScreen(ba.Activity):
ts_height = 300
ts_h_offs = -480
v_offs = 40
Text(ba.Lstr(resource='yourBestScoresText')
if self._score_type == 'points' else ba.Lstr(
resource='yourBestTimesText'),
Text(ba.Lstr(resource='yourBestScoresText') if self._score_type
== 'points' else ba.Lstr(resource='yourBestTimesText'),
maxwidth=210,
position=(ts_h_offs - 10, ts_height / 2 + 25 + v_offs + 20),
transition=Text.Transition.IN_RIGHT,

View File

@ -858,11 +858,10 @@ class Bomb(ba.Actor):
except Exception:
node_delegate = None
if node:
if (self.bomb_type == 'impact'
and (node is self.owner or
(isinstance(node_delegate, Bomb)
and node_delegate.bomb_type == 'impact'
and node_delegate.owner is self.owner))):
if (self.bomb_type == 'impact' and
(node is self.owner or
(isinstance(node_delegate, Bomb) and node_delegate.bomb_type
== 'impact' and node_delegate.owner is self.owner))):
return
self.handlemessage(ExplodeMessage())

View File

@ -282,9 +282,8 @@ class SpazBot(basespaz.Spaz):
# Not a flag-bearer. If we're holding anything but a bomb, drop it.
if self.node.hold_node:
try:
holding_bomb = (self.node.hold_node.getnodetype() in [
'bomb', 'prop'
])
holding_bomb = (self.node.hold_node.getnodetype()
in ['bomb', 'prop'])
except Exception:
holding_bomb = False
if not holding_bomb:

View File

@ -33,10 +33,10 @@ class AppDelegate(ba.AppDelegate):
"""Defines handlers for high level app functionality."""
def create_default_game_config_ui(
self, gameclass: Type[ba.GameActivity], sessionclass: Type[ba.Session],
config: Optional[Dict[str, Any]],
completion_call: Callable[[Optional[Dict[str, Any]]], Any]
) -> None:
self, gameclass: Type[ba.GameActivity],
sessionclass: Type[ba.Session], config: Optional[Dict[str, Any]],
completion_call: Callable[[Optional[Dict[str, Any]]],
Any]) -> None:
"""(internal)"""
# Replace the main window once we come up successfully.

View File

@ -585,8 +585,8 @@ class FootballCoopGame(ba.CoopGameActivity):
for player in self.players:
if player.actor:
assert isinstance(player.actor, playerspaz.PlayerSpaz)
if (player.actor.is_alive() and
player.actor.node.hold_node == self._flag.node):
if (player.actor.is_alive() and player.actor.node.hold_node
== self._flag.node):
return
flagpos = ba.Vec3(self._flag.node.position)

View File

@ -213,22 +213,22 @@ class AccountSettingsWindow(ba.Window):
show_signing_in_text = account_state == 'signing_in'
signing_in_text_space = 80.0
show_google_play_sign_in_button = (
account_state == 'signed_out'
and 'Google Play' in self._show_sign_in_buttons)
show_game_circle_sign_in_button = (
account_state == 'signed_out'
and 'Game Circle' in self._show_sign_in_buttons)
show_google_play_sign_in_button = (account_state == 'signed_out'
and 'Google Play'
in self._show_sign_in_buttons)
show_game_circle_sign_in_button = (account_state == 'signed_out'
and 'Game Circle'
in self._show_sign_in_buttons)
show_ali_sign_in_button = (account_state == 'signed_out'
and 'Ali' in self._show_sign_in_buttons)
show_test_sign_in_button = (account_state == 'signed_out'
and 'Test' in self._show_sign_in_buttons)
show_device_sign_in_button = (account_state == 'signed_out' and
'Local' in self._show_sign_in_buttons)
show_device_sign_in_button = (account_state == 'signed_out' and 'Local'
in self._show_sign_in_buttons)
sign_in_button_space = 70.0
show_game_service_button = (
self._signed_in and account_type in ['Game Center', 'Game Circle'])
show_game_service_button = (self._signed_in and account_type
in ['Game Center', 'Game Circle'])
game_service_button_space = 60.0
show_linked_accounts_text = (self._signed_in
@ -236,9 +236,9 @@ class AccountSettingsWindow(ba.Window):
'allowAccountLinking2', False))
linked_accounts_text_space = 60.0
show_achievements_button = (self._signed_in and
account_type in ('Google Play', 'Alibaba',
'Local', 'OUYA', 'Test'))
show_achievements_button = (self._signed_in and account_type
in ('Google Play', 'Alibaba', 'Local',
'OUYA', 'Test'))
achievements_button_space = 60.0
show_achievements_text = (self._signed_in
@ -268,9 +268,8 @@ class AccountSettingsWindow(ba.Window):
show_unlink_accounts_button = show_link_accounts_button
unlink_accounts_button_space = 90.0
show_sign_out_button = (
self._signed_in
and account_type in ['Test', 'Local', 'Google Play'])
show_sign_out_button = (self._signed_in and account_type
in ['Test', 'Local', 'Google Play'])
sign_out_button_space = 70.0
if self._subcontainer is not None:

View File

@ -234,9 +234,8 @@ class AccountViewerWindow(popup.PopupWindow):
character = ba.app.spaz_appearances.get(
profile['character'], None)
if character is not None:
tint_color = (profile['color']
if 'color' in profile else
(1, 1, 1))
tint_color = (profile['color'] if 'color'
in profile else (1, 1, 1))
tint2_color = (profile['highlight']
if 'highlight' in profile else
(1, 1, 1))

View File

@ -388,8 +388,8 @@ class CoopBrowserWindow(ba.Window):
ba.textwidget(edit=tbtn['prize_value_1_text'],
text='-' if pv1 == '' else pv1,
scale=prize_value_scale_large if
ticket_char not in pv1 else prize_value_scale_small,
scale=prize_value_scale_large if ticket_char
not in pv1 else prize_value_scale_small,
position=(tbtn['button_x'] + 380 + x_offs,
tbtn['button_y'] + tbtn['button_scale_y'] -
93 + prize_y_offs))
@ -401,8 +401,8 @@ class CoopBrowserWindow(ba.Window):
93 - 45 + prize_y_offs))
ba.textwidget(edit=tbtn['prize_value_2_text'],
text=pv2,
scale=prize_value_scale_large if
ticket_char not in pv2 else prize_value_scale_small,
scale=prize_value_scale_large if ticket_char
not in pv2 else prize_value_scale_small,
position=(tbtn['button_x'] + 380 + x_offs,
tbtn['button_y'] + tbtn['button_scale_y'] -
93 - 45 + prize_y_offs))
@ -414,8 +414,8 @@ class CoopBrowserWindow(ba.Window):
93 - 90 + prize_y_offs))
ba.textwidget(edit=tbtn['prize_value_3_text'],
text=pv3,
scale=prize_value_scale_large if
ticket_char not in pv3 else prize_value_scale_small,
scale=prize_value_scale_large if ticket_char
not in pv3 else prize_value_scale_small,
position=(tbtn['button_x'] + 380 + x_offs,
tbtn['button_y'] + tbtn['button_scale_y'] -
93 - 90 + prize_y_offs))
@ -425,12 +425,12 @@ class CoopBrowserWindow(ba.Window):
if entry['scores']:
score = tbtn['leader'] = copy.deepcopy(entry['scores'][0])
leader_name = score[1]
leader_score = (
ba.timestring(score[0] * 10,
centi=True,
timeformat=ba.TimeFormat.MILLISECONDS,
suppress_format_warning=True)
if entry['scoreType'] == 'time' else str(score[0]))
leader_score = (ba.timestring(
score[0] * 10,
centi=True,
timeformat=ba.TimeFormat.MILLISECONDS,
suppress_format_warning=True) if entry['scoreType']
== 'time' else str(score[0]))
else:
tbtn['leader'] = None

View File

@ -228,9 +228,9 @@ class FileSelectorWindow(ba.Window):
if not self._root_widget:
return
scrollwidget_selected = (
self._scrollwidget is None
or self._root_widget.get_selected_child() == self._scrollwidget)
scrollwidget_selected = (self._scrollwidget is None
or self._root_widget.get_selected_child()
== self._scrollwidget)
in_top_folder = (self._path == self._base_path)
hide_top_folder = in_top_folder and self._show_base_path is False

View File

@ -402,8 +402,8 @@ class MainMenuWindow(ba.Window):
scale=3.0 * t_scale)
def _refresh_not_in_game(
self, positions: List[Tuple[float, float, float]]
) -> Tuple[float, float, float]:
self, positions: List[Tuple[float, float,
float]]) -> Tuple[float, float, float]:
# pylint: disable=too-many-branches
# pylint: disable=too-many-locals
# pylint: disable=too-many-statements
@ -659,8 +659,8 @@ class MainMenuWindow(ba.Window):
return h, v, scale
def _refresh_in_game(
self, positions: List[Tuple[float, float, float]]
) -> Tuple[float, float, float]:
self, positions: List[Tuple[float, float,
float]]) -> Tuple[float, float, float]:
# pylint: disable=too-many-branches
# pylint: disable=too-many-locals
# pylint: disable=too-many-statements

View File

@ -566,8 +566,8 @@ class PlaylistBrowserWindow(ba.Window):
from bastd.ui import playoptions
# Make sure the target playlist still exists.
try:
exists = (playlist_name == '__default__' or
playlist_name in ba.app.config[self._config_name_full])
exists = (playlist_name == '__default__' or playlist_name
in ba.app.config[self._config_name_full])
except Exception:
exists = False
if not exists:

View File

@ -268,8 +268,9 @@ class PlaylistEditWindow(ba.Window):
from bastd.ui.playlist import customizebrowser as cb
new_name = cast(str, ba.textwidget(query=self._text_field))
if (new_name != self._editcontroller.get_existing_playlist_name()
and new_name in ba.app.config[
self._editcontroller.get_config_name() + ' Playlists']):
and new_name
in ba.app.config[self._editcontroller.get_config_name() +
' Playlists']):
ba.screenmessage(
ba.Lstr(resource=self._r + '.cantSaveAlreadyExistsText'))
ba.playsound(ba.getsound('error'))

View File

@ -490,11 +490,10 @@ class AdvancedSettingsWindow(ba.Window):
text_scale=1.0,
on_activate_call=self._on_benchmark_press)
ba.widget(
edit=self._vr_test_button
if self._vr_test_button is not None else self._net_test_button
if self._net_test_button is not None else self._benchmarks_button,
up_widget=cbw)
ba.widget(edit=self._vr_test_button if self._vr_test_button is not None
else self._net_test_button if self._net_test_button
is not None else self._benchmarks_button,
up_widget=cbw)
for child in self._subcontainer.get_children():
ba.widget(edit=child, show_buffer_bottom=30, show_buffer_top=20)
@ -580,8 +579,8 @@ class AdvancedSettingsWindow(ba.Window):
elif sel == self._kick_idle_players_check_box.widget:
sel_name = 'KickIdlePlayers'
elif (self._always_use_internal_keyboard_check_box is not None
and sel ==
self._always_use_internal_keyboard_check_box.widget):
and sel
== self._always_use_internal_keyboard_check_box.widget):
sel_name = 'AlwaysUseInternalKeyboard'
elif (self._language_popup is not None
and sel == self._language_popup.get_button()):
@ -632,8 +631,8 @@ class AdvancedSettingsWindow(ba.Window):
elif sel_name == 'KickIdlePlayers':
sel = self._kick_idle_players_check_box.widget
elif (sel_name == 'AlwaysUseInternalKeyboard'
and self._always_use_internal_keyboard_check_box is
not None):
and self._always_use_internal_keyboard_check_box
is not None):
sel = self._always_use_internal_keyboard_check_box.widget
elif (sel_name == 'Languages'
and self._language_popup is not None):

View File

@ -497,13 +497,11 @@ class GamepadSettingsWindow(ba.Window):
# This actually shows both LR and UD.
sval1 = (self._settings['analogStickLR' +
self._ext] if 'analogStickLR' +
self._ext in self._settings else
5 if self._is_secondary else 1)
self._ext] if 'analogStickLR' + self._ext
in self._settings else 5 if self._is_secondary else 1)
sval2 = (self._settings['analogStickUD' +
self._ext] if 'analogStickUD' +
self._ext in self._settings else
6 if self._is_secondary else 2)
self._ext] if 'analogStickUD' + self._ext
in self._settings else 6 if self._is_secondary else 2)
return self._input.get_axis_name(
sval1) + ' / ' + self._input.get_axis_name(sval2)
@ -769,13 +767,13 @@ class AwaitGamepadInputWindow(ba.Window):
"""Window for capturing a gamepad button press."""
def __init__(
self,
gamepad: ba.InputDevice,
button: str,
callback: Callable[[str, Dict[str, Any], AwaitGamepadInputWindow],
Any],
message: ba.Lstr = None,
message2: ba.Lstr = None):
self,
gamepad: ba.InputDevice,
button: str,
callback: Callable[[str, Dict[str, Any], AwaitGamepadInputWindow],
Any],
message: ba.Lstr = None,
message2: ba.Lstr = None):
if message is None:
print('AwaitGamepadInputWindow message is None!')
message = ba.Lstr(

View File

@ -73,10 +73,9 @@ class SoundtrackEditWindow(ba.Window):
parent=self._root_widget,
position=(0, self._height - 50),
size=(self._width, 25),
text=ba.Lstr(
resource=self._r +
('.editSoundtrackText' if existing_soundtrack is not None else
'.newSoundtrackText')),
text=ba.Lstr(resource=self._r +
('.editSoundtrackText' if existing_soundtrack
is not None else '.newSoundtrackText')),
color=ba.app.title_color,
h_align="center",
v_align="center",

View File

@ -732,8 +732,8 @@ class StoreBrowserWindow(ba.Window):
dummy_name = ''
section['button_size'] = get_store_item_display_size(
dummy_name)
section['v_spacing'] = (
-17 if self._tab == 'characters' else 0)
section['v_spacing'] = (-17 if self._tab
== 'characters' else 0)
if 'title' not in section:
section['title'] = ''
section['x_offs'] = (130 if self._tab == 'extras' else

View File

@ -162,12 +162,11 @@ class EntityMixin:
cls=ExtendedJSONEncoder)
# When not doing pretty, go for quick and compact.
return json.dumps(
data,
separators=(',', ':'),
sort_keys=(sort_keys_override
if sort_keys_override is not None else False),
cls=ExtendedJSONEncoder)
return json.dumps(data,
separators=(',', ':'),
sort_keys=(sort_keys_override if sort_keys_override
is not None else False),
cls=ExtendedJSONEncoder)
@staticmethod
def json_loads(s: str) -> Any:

View File

@ -109,8 +109,8 @@ def have_matching_fields(val1: CompoundValue, val2: CompoundValue) -> bool:
def get_compound_value_and_data(
obj: Union[BoundCompoundValue, CompoundValue]
) -> Tuple[CompoundValue, Any]:
obj: Union[BoundCompoundValue,
CompoundValue]) -> Tuple[CompoundValue, Any]:
"""Return value and data for bound or unbound compound values."""
# pylint: disable=cyclic-import
from efro.entity._support import BoundCompoundValue

View File

@ -170,8 +170,9 @@ if TYPE_CHECKING:
"""Seven argument variant of call wrapper"""
def __init__(
self, _call: Callable[[In1T, In2T, In3T, In4T, In5T, In6T, In7T],
OutT]):
self,
_call: Callable[[In1T, In2T, In3T, In4T, In5T, In6T, In7T],
OutT]):
...
def __call__(self, _arg1: In1T, _arg2: In2T, _arg3: In3T, _arg4: In4T,

View File

@ -85,8 +85,8 @@ class DispatchMethodWrapper(Generic[TARG, TRET]):
# noinspection PyTypeHints, PyProtectedMember
def dispatchmethod(
func: Callable[[Any, TARG], TRET]
) -> DispatchMethodWrapper[TARG, TRET]:
func: Callable[[Any, TARG],
TRET]) -> DispatchMethodWrapper[TARG, TRET]:
"""A variation of functools.singledispatch for methods."""
from functools import singledispatch, update_wrapper
origwrapper: Any = singledispatch(func)
@ -250,8 +250,8 @@ class ValueDispatcher(Generic[TVAL, TRET]):
def valuedispatch1arg(
call: Callable[[TVAL, TARG], TRET]
) -> ValueDispatcher1Arg[TVAL, TARG, TRET]:
call: Callable[[TVAL, TARG],
TRET]) -> ValueDispatcher1Arg[TVAL, TARG, TRET]:
"""Like valuedispatch but for functions taking an extra argument."""
return ValueDispatcher1Arg(call)

View File

@ -1,5 +1,5 @@
<!-- THIS FILE IS AUTO GENERATED; DO NOT EDIT BY HAND -->
<h4><em>last updated on 2020-04-24 for Ballistica version 1.5.0 build 20001</em></h4>
<h4><em>last updated on 2020-04-25 for Ballistica version 1.5.0 build 20001</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>

View File

@ -40,7 +40,7 @@ CLREND = '\033[0m' # End.
REQUIRED_PYTHON_MODULES = [
('pylint', [2, 4, 4], None),
('mypy', [0, 770], None),
('yapf', [0, 29, 0], None),
('yapf', [0, 30, 0], None),
('typing_extensions', None, None),
('pytz', None, None),
('yaml', None, 'PyYAML'),