Skip to content

Commit 980f6fc

Browse files
committed
🚨 Linting fixes
1 parent 72d2b1a commit 980f6fc

6 files changed

Lines changed: 19 additions & 14 deletions

File tree

examples/list_and_switch_devices_example.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
22
Example to list and switch devices.
33
"""
44

5-
from pycaw.constants import EDataFlow, DEVICE_STATE
5+
import warnings
6+
7+
from pycaw.constants import DEVICE_STATE, EDataFlow
68
from pycaw.pycaw import AudioUtilities
79
from pycaw.utils import AudioDevice
8-
import warnings
910

1011

1112
def get_active_output_devices():
1213
with warnings.catch_warnings(): # suppress COMError warnings
1314
warnings.simplefilter("ignore", UserWarning)
14-
return AudioUtilities.GetAllDevices(data_flow=EDataFlow.eRender.value,
15-
device_state=DEVICE_STATE.ACTIVE.value)
15+
return AudioUtilities.GetAllDevices(
16+
data_flow=EDataFlow.eRender.value, device_state=DEVICE_STATE.ACTIVE.value
17+
)
1618

1719

1820
def get_default_device():

examples/volume_callback_example.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"""
55

66
from comtypes import COMObject
7+
78
from pycaw.pycaw import AudioUtilities, IAudioEndpointVolumeCallback
89

910

pycaw/api/policyconfig/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from ctypes import HRESULT, POINTER
22
from ctypes.wintypes import BOOL, DWORD, LPCWSTR
3+
34
from comtypes import COMMETHOD, GUID, IUnknown
45

56
from pycaw.api.mmdeviceapi import PROPERTYKEY

pycaw/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
IID_Empty = GUID("{00000000-0000-0000-0000-000000000000}")
66

77
CLSID_MMDeviceEnumerator = GUID("{BCDE0395-E52F-467C-8E3D-C4579291692E}")
8-
CLSID_CPolicyConfigClient = GUID('{870af99c-171d-4f9e-af0d-e63df40c2bc9}')
8+
CLSID_CPolicyConfigClient = GUID("{870af99c-171d-4f9e-af0d-e63df40c2bc9}")
99

1010

1111
class ERole(Enum):

pycaw/utils.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
DEVICE_STATE,
1414
STGM,
1515
AudioDeviceState,
16+
CLSID_CPolicyConfigClient,
1617
CLSID_MMDeviceEnumerator,
1718
EDataFlow,
1819
ERole,
1920
IID_Empty,
20-
CLSID_CPolicyConfigClient,
2121
)
2222

2323

@@ -266,18 +266,17 @@ def CreateDevice(dev):
266266
return AudioDevice(id, audioState, properties, dev)
267267

268268
@staticmethod
269-
def GetAllDevices(data_flow=EDataFlow.eAll.value,
270-
device_state=DEVICE_STATE.MASK_ALL.value):
269+
def GetAllDevices(
270+
data_flow=EDataFlow.eAll.value, device_state=DEVICE_STATE.MASK_ALL.value
271+
):
271272
devices = []
272273
deviceEnumerator = comtypes.CoCreateInstance(
273274
CLSID_MMDeviceEnumerator, IMMDeviceEnumerator, comtypes.CLSCTX_INPROC_SERVER
274275
)
275276
if deviceEnumerator is None:
276277
return devices
277278

278-
collection = deviceEnumerator.EnumAudioEndpoints(
279-
data_flow, device_state
280-
)
279+
collection = deviceEnumerator.EnumAudioEndpoints(data_flow, device_state)
281280
if collection is None:
282281
return devices
283282

@@ -325,5 +324,7 @@ def SetDefaultDevice(devId, roles=None):
325324
for role in roles:
326325
hr = policy_config.SetDefaultEndpoint(devId, role.value)
327326
if hr != 0:
328-
raise OSError(f"SetDefaultEndpoint failed for role {role} "
329-
f"with HRESULT {hr:#x}")
327+
raise OSError(
328+
f"SetDefaultEndpoint failed for role {role} "
329+
f"with HRESULT {hr:#x}"
330+
)

tests/test_examples.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def test_audio_endpoint_volume_example(self):
2020
audio_endpoint_volume_example.main()
2121
output = out.getvalue()
2222
lines = output.split("\n")
23-
assert lines[0].startswith('Device found: ')
23+
assert lines[0].startswith("Device found: ")
2424
assert lines[1] == "volume.GetMute(): 0"
2525
assert lines[2] == "volume.GetMasterVolumeLevel(): -20.0"
2626
assert lines[3] == "volume.GetVolumeRange(): (-95.25, 0.0, 0.75)"

0 commit comments

Comments
 (0)