Skip to content

Commit

Permalink
Fix mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanlatr committed Oct 26, 2024
1 parent cdef965 commit 2033d65
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pydoctor/astbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
get_docstring_node, get_assign_docstring_node, unparse, NodeVisitor, Parentage, Str)

class InvalidSignatureParamName(str):
def isidentifier(self):
def isidentifier(self) -> bool:
return True

def parseFile(path: Path) -> ast.Module:
Expand Down
2 changes: 1 addition & 1 deletion pydoctor/epydoc/markup/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ def __init__(self, other: ParsedDocstring, *, tag: Tag) -> None:
self._tag = tag

@property
def has_body(self):
def has_body(self) -> bool:
return self._parsed.has_body

def to_stan(self, linker: DocstringLinker) -> Tag:
Expand Down
2 changes: 1 addition & 1 deletion pydoctor/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ class FunctionOverload:
"""
primary: Function
signature: Signature
decorators: Sequence[ast.expr] = attr.ib(converter=tuple)
decorators: Sequence[ast.expr]
parsed_signature: ParsedDocstring | None = None # set in get_parsed_signature()

class Attribute(Inheritable):
Expand Down
1 change: 1 addition & 0 deletions pydoctor/test/test_astbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def to_html(

def signature2str(func: model.Function | model.FunctionOverload) -> str:
doc = get_parsed_signature(func)
assert doc
fromhtml = flatten_text(format_signature(func))
fromdocutils = ''.join(node2stan.gettext(doc.to_node()))
assert fromhtml == fromdocutils
Expand Down
12 changes: 6 additions & 6 deletions pydoctor/test/test_epydoc2stan.py
Original file line number Diff line number Diff line change
Expand Up @@ -1977,9 +1977,9 @@ def f(self, x:typ) -> typ:
assert isinstance(f, model.Function)
assert f.signature
assert "href" in flatten(epydoc2stan._colorize_signature_annotation(
f.signature.parameters['x'].annotation, f).to_stan(None))
f.signature.parameters['x'].annotation, f).to_stan(NotFoundLinker()))
assert "href" in flatten(epydoc2stan._colorize_signature_annotation(
f.signature.return_annotation, f).to_stan(None))
f.signature.return_annotation, f).to_stan(NotFoundLinker()))

assert isinstance(var, model.Attribute)
assert "href" in flatten(epydoc2stan.type2stan(var) or '')
Expand Down Expand Up @@ -2008,12 +2008,12 @@ def f(self, x:typ) -> typ:
assert isinstance(f, model.Function)
assert f.signature
assert 'href="index.html#typ"' in flatten(epydoc2stan._colorize_signature_annotation(
f.signature.parameters['x'].annotation, f).to_stan(None))
# the linker can be None here because the annotations uses with_linker()
f.signature.parameters['x'].annotation, f).to_stan(NotFoundLinker()))
# the linker can be NotFoundLinker() here because the annotations uses with_linker()

assert 'href="index.html#typ"' in flatten(epydoc2stan._colorize_signature_annotation(
f.signature.return_annotation, f).to_stan(None))
# the linker can be None here because the annotations uses with_linker()
f.signature.return_annotation, f).to_stan(NotFoundLinker()))
# the linker can be NotFoundLinker() here because the annotations uses with_linker()

assert isinstance(var, model.Attribute)
assert 'href="index.html#typ"' in flatten(epydoc2stan.type2stan(var) or '')
Expand Down

0 comments on commit 2033d65

Please sign in to comment.