Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
timtucker committed Sep 21, 2024
1 parent 6dc20f4 commit 25fcce2
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions pycaw/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import warnings
from typing import List, TypeVar, Generic
from __future__ import annotations

import warnings
from typing import Generic, List, TypeVar

import comtypes
import psutil
from _ctypes import COMError
Expand All @@ -22,7 +23,8 @@
)

# Define a type variable that extends IUnknown
COMInterface = TypeVar('COMInterface', bound='IUnknown')
COMInterface = TypeVar("COMInterface", bound="IUnknown")


class AudioDevice:
"""
Expand Down Expand Up @@ -65,7 +67,7 @@ def state(self) -> AudioDeviceState:
state = self._dev.GetState()
self._state = AudioDeviceState(state)
return self._state

@staticmethod
def getProperty(self, key):
store = self._dev.OpenPropertyStore(STGM.STGM_READ.value)
Expand All @@ -76,10 +78,10 @@ def getProperty(self, key):
for j in range(propCount):
pk = store.GetAt(j)
name = str(pk)

if name != key:
continue

try:
value = store.GetValue(pk)
v = value.GetValue()
Expand All @@ -103,11 +105,11 @@ def properties(self) -> dict:
propCount = store.GetCount()
for j in range(propCount):
pk = store.GetAt(j)

value = AudioDevice.getProperty(self, pk)
if value is None:
continue

name = str(pk)
properties[name] = value
self._properties = properties
Expand Down Expand Up @@ -355,11 +357,15 @@ def GetSessions(
return sessions

@staticmethod
def GetPlaybackSessions(sessionState: AudioDeviceState = None) -> List[AudioSession]:
def GetPlaybackSessions(
sessionState: AudioDeviceState = None,
) -> List[AudioSession]:
return AudioUtilities.GetSessions(EDataFlow.eRender.value, sessionState)

@staticmethod
def GetRecordingSessions(sessionState: AudioDeviceState = None) -> List[AudioSession]:
def GetRecordingSessions(
sessionState: AudioDeviceState = None,
) -> List[AudioSession]:
return AudioUtilities.GetSessions(EDataFlow.eCapture.value, sessionState)

@staticmethod
Expand Down Expand Up @@ -401,7 +407,9 @@ def CreateDevices(collection) -> List[AudioDevice]:
return devices

@staticmethod
def GetDevices(flow=EDataFlow.eAll.value, deviceState=DEVICE_STATE.ACTIVE.value) -> List[AudioDevice]:
def GetDevices(
flow=EDataFlow.eAll.value, deviceState=DEVICE_STATE.ACTIVE.value
) -> List[AudioDevice]:
"""
Get devices based on filteres for flow direction and device state.
Default to returning active devices.
Expand Down

0 comments on commit 25fcce2

Please sign in to comment.