Skip to content

Commit

Permalink
enable aconfig flags: fix lint and formatting
Browse files Browse the repository at this point in the history
Bug: 372300895
  • Loading branch information
jrotkiewicz committed Dec 19, 2024
1 parent 6b3fd64 commit 938e582
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions avatar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ def normalize(a: Any) -> Any:
return wrapper


def enableFlag(flag):
""" Enable aconfig flag.
def enableFlag(flag: str) -> Callable[..., Any]:
"""Enable aconfig flag.
Requires that the test class declares a devices: Optional[PandoraDevices] attribute.
Expand All @@ -220,28 +220,24 @@ def enableFlag(flag):
TypeError: when the provided flag argument is not a string
"""

def decorator(func):
def decorator(func: Callable[..., Any]) -> Callable[..., Any]:

@functools.wraps(func)
def wrapper(self, *args, **kwargs):
def wrapper(self: base_test.BaseTestClass, *args: Any, **kwargs: Any) -> Any:
devices = getattr(self, 'devices', None)

if not devices:
raise AttributeError(
"Attribute 'devices' not found in test class or is None")
raise AttributeError("Attribute 'devices' not found in test class or is None")

if not isinstance(devices, PandoraDevices):
raise TypeError(
"devices attribute must be of a PandoraDevices type")
raise TypeError("devices attribute must be of a PandoraDevices type")

if not isinstance(flag, str):
raise TypeError("flag must be a string")

for server in devices._servers:
if isinstance(server, pandora_server.AndroidPandoraServer):
server.device.adb.shell(
['device_config override bluetooth', flag,
'true']) # type: ignore
server.device.adb.shell(['device_config override bluetooth', flag, 'true']) # type: ignore
break
return func(self, *args, **kwargs)

Expand Down

0 comments on commit 938e582

Please sign in to comment.