Skip to content

Commit

Permalink
Fix docstring and add indicative exception messages
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanlatr committed Sep 14, 2024
1 parent 674ce69 commit a38c793
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pydoctor/astbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -796,22 +796,22 @@ def _contextualizeTarget(self, target:ast.expr) -> Tuple[model.Documentable, str
Find out the documentatble wich is the parent of the assignment's target as well as it's name.
@returns: Tuple C{parent, name}.
@raises: L{ValueError} if the target does not bind a new variable.
@raises ValueError: if the target does not bind a new variable.
"""
dottedname = node2dottedname(target)
if not dottedname or len(dottedname) > 2:
raise ValueError()
raise ValueError('does not bind a new variable')
parent: model.Documentable
if len(dottedname) == 2 and dottedname[0] == 'self':
# an instance variable.
# TODO: This currently only works if the first argument of methods
# is named 'self'.
if (maybe_cls:=self._getClassFromMethodContext()) is None:
raise ValueError()
raise ValueError('using self in unsupported context')
dottedname = dottedname[1:]
parent = maybe_cls
elif len(dottedname) != 1:
raise ValueError()
raise ValueError('does not bind a new variable')
else:
parent = self.builder.current
return parent, dottedname[0]
Expand Down

0 comments on commit a38c793

Please sign in to comment.