Skip to content

Commit

Permalink
..
Browse files Browse the repository at this point in the history
  • Loading branch information
dweindl committed Apr 16, 2024
1 parent 0ab2a2d commit c0f1d8b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
6 changes: 3 additions & 3 deletions python/sdist/amici/swig.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def visit_FunctionDef(self, node):
for arg in node.args.args:
if not arg.annotation:
continue
if isinstance(arg.annotation, ast.Name):
if not isinstance(arg.annotation, ast.Constant):
# there is already proper annotation
continue

Expand Down Expand Up @@ -133,15 +133,15 @@ def _annotation_from_docstring(self, node: ast.FunctionDef):
for line_no, line in enumerate(docstring):
if (
match := re.match(
r"\s*:rtype:\s*(?::py:class:`)?(\w+)`?\s*$", line
r"\s*:rtype:\s*(?::py:class:`)?(.+)`?\s*$", line
)
) and not match.group(1).startswith(":"):
node.returns = ast.Constant(match.group(1))
lines_to_remove.add(line_no)

if (
match := re.match(
r"\s*:type\s*(\w+):\W*(?::py:class:`)?(\w+)`?\s*$", line
r"\s*:type\s*(\w+):\W*(?::py:class:`)?(.+)`?\s*$", line
)
) and not match.group(1).startswith(":"):
for arg in node.args.args:
Expand Down
9 changes: 2 additions & 7 deletions swig/amici.i
Original file line number Diff line number Diff line change
Expand Up @@ -373,13 +373,8 @@ __all__ = [


def _get_ptr(
obj: Union[AmiciModel, AmiciExpData, AmiciSolver, AmiciReturnData],
) -> Union[
Model,
ExpData,
Solver,
ReturnData,
]:
obj: AmiciModel | AmiciExpData | AmiciSolver | AmiciReturnData,
) -> Model | ExpData | Solver | ReturnData:
"""
Convenience wrapper that returns the smart pointer pointee, if applicable
Expand Down

0 comments on commit c0f1d8b

Please sign in to comment.