Skip to content

Commit efeb97c

Browse files
Use TypeError instead of AssertionError
1 parent f5b7336 commit efeb97c

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

distutils/extension.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,19 +107,19 @@ def __init__(
107107
**kw, # To catch unknown keywords
108108
):
109109
if not isinstance(name, str):
110-
raise AssertionError("'name' must be a string") # noqa: TRY004
110+
raise TypeError("'name' must be a string") # noqa: TRY004
111111

112112
# handle the string case first; since strings are iterable, disallow them
113113
if isinstance(sources, str):
114-
raise AssertionError( # noqa: TRY004
114+
raise TypeError(
115115
"'sources' must be an iterable of strings or PathLike objects, not a string"
116116
)
117117

118118
# now we check if it's iterable and contains valid types
119119
try:
120120
self.sources = list(map(os.fspath, sources))
121121
except TypeError:
122-
raise AssertionError(
122+
raise TypeError(
123123
"'sources' must be an iterable of strings or PathLike objects"
124124
)
125125

distutils/tests/test_extension.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,16 @@ def test_read_setup_file(self):
6363

6464
def test_extension_init(self):
6565
# the first argument, which is the name, must be a string
66-
with pytest.raises(AssertionError):
66+
with pytest.raises(TypeError):
6767
Extension(1, [])
6868
ext = Extension('name', [])
6969
assert ext.name == 'name'
7070

7171
# the second argument, which is the list of files, must
7272
# be an iterable of strings or PathLike objects, and not a string
73-
with pytest.raises(AssertionError):
73+
with pytest.raises(TypeError):
7474
Extension('name', 'file')
75-
with pytest.raises(AssertionError):
75+
with pytest.raises(TypeError):
7676
Extension('name', ['file', 1])
7777
ext = Extension('name', ['file1', 'file2'])
7878
assert ext.sources == ['file1', 'file2']

0 commit comments

Comments
 (0)