File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -155,6 +155,22 @@ class EntryPoint:
155155 'attr'
156156 >>> ep.extras
157157 ['extra1', 'extra2']
158+
159+ If the value package or module are not valid identifiers, a
160+ ValueError is raised on access.
161+
162+ >>> EntryPoint(name=None, group=None, value='invalid-name').module
163+ Traceback (most recent call last):
164+ ...
165+ ValueError: ('Invalid object reference...invalid-name...
166+ >>> EntryPoint(name=None, group=None, value='invalid-name').attr
167+ Traceback (most recent call last):
168+ ...
169+ ValueError: ('Invalid object reference...invalid-name...
170+ >>> EntryPoint(name=None, group=None, value='invalid-name').extras
171+ Traceback (most recent call last):
172+ ...
173+ ValueError: ('Invalid object reference...invalid-name...
158174 """
159175
160176 pattern = re .compile (
@@ -211,7 +227,13 @@ def extras(self) -> list[str]:
211227 @property
212228 def _match (self ) -> _EntryPointMatch :
213229 match = self .pattern .match (self .value )
214- assert match is not None
230+ if not match :
231+ raise ValueError (
232+ 'Invalid object reference. '
233+ 'See https://packaging.python.org'
234+ '/en/latest/specifications/entry-points/#data-model' ,
235+ self .value ,
236+ )
215237 return _EntryPointMatch (** match .groupdict ())
216238
217239 def _for (self , dist ):
You can’t perform that action at this time.
0 commit comments