Skip to content

Commit 295982c

Browse files
Heed pylint's warnings
Addressed pylint's dangerous-default-value / W0102 Also fixed processing of str inputs, which would process it into a list of characters in strings, as opposed to the list with one element that is the argument string. Fixed pylint unidiomatic-typecheck / C0123 Use [] instead of list() per pylint
1 parent 32a99c7 commit 295982c

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

dpctl/_device_selection.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from ._sycl_device_factory import get_devices
2222

2323

24-
def select_device_with_aspects(required_aspects, excluded_aspects=[]):
24+
def select_device_with_aspects(required_aspects, excluded_aspects=None):
2525
"""Selects the root :class:`dpctl.SyclDevice` that has the highest
2626
default selector score among devices that have all aspects in the
2727
`required_aspects` list, and do not have any aspects in `excluded_aspects`
@@ -41,10 +41,16 @@ def select_device_with_aspects(required_aspects, excluded_aspects=[]):
4141
dpctl.select_device_with_aspects(
4242
['usm_shared_allocations'], excluded_aspects=['custom'])
4343
"""
44+
if excluded_aspects is None:
45+
excluded_aspects = []
4446
if isinstance(required_aspects, str):
45-
required_aspects = [required_aspects]
47+
required_aspects = [
48+
required_aspects,
49+
]
4650
if isinstance(excluded_aspects, str):
47-
excluded_aspects = [excluded_aspects]
51+
excluded_aspects = [
52+
excluded_aspects,
53+
]
4854
seq = collections.abc.Sequence
4955
input_types_ok = isinstance(required_aspects, seq) and isinstance(
5056
excluded_aspects, seq
@@ -55,7 +61,7 @@ def select_device_with_aspects(required_aspects, excluded_aspects=[]):
5561
"e.g. lists, of strings"
5662
)
5763
for asp in chain(required_aspects, excluded_aspects):
58-
if type(asp) != str:
64+
if not isinstance(asp, str):
5965
raise TypeError("The list objects must be of a string type")
6066
if not hasattr(SyclDevice, "has_aspect_" + asp):
6167
raise AttributeError(f"The {asp} aspect is not supported in dpctl")

0 commit comments

Comments
 (0)