Skip to content
Permalink
Browse files

MNT: mypy/typing fixes

  • Loading branch information...
kernc committed Apr 24, 2019
1 parent 71b1783 commit 43f28dde6fd97ff1472bf984ebd4afa3e4d5ab6b
Showing with 9 additions and 7 deletions.
  1. +5 −3 pdoc/cli.py
  2. +4 −4 pdoc/test/__init__.py
@@ -290,6 +290,7 @@ def _quit_if_exists(m: pdoc.Module, ext: str):


def write_files(m: pdoc.Module, ext: str, **kwargs):
assert ext in ('.html', '.md')
f = module_path(m, ext=ext)

dirpath = path.dirname(f)
@@ -298,9 +299,10 @@ def write_files(m: pdoc.Module, ext: str, **kwargs):

try:
with open(f, 'w+', encoding='utf-8') as w:
method = {'.html': m.html,
'.md': m.text}[ext]
w.write(method(**kwargs))
if ext == '.html':
w.write(m.html(**kwargs))
elif ext == '.md':
w.write(m.html(**kwargs))
except Exception:
try:
os.unlink(f)
@@ -596,19 +596,19 @@ def test_Function_params(self):
self.assertEqual(func.params(), ['a=os.environ'])

# typed
def f(a: int, *b, c: typing.List[pdoc.Doc] = ''): pass
def f(a: int, *b, c: typing.List[pdoc.Doc] = []): pass
func = pdoc.Function('f', mod, f)
self.assertEqual(func.params(), ['a', '*b', "c=''"])
self.assertEqual(func.params(), ['a', '*b', "c=[]"])
self.assertEqual(func.params(annotate=True),
['a:\xA0int', '*b', "c:\xA0List[pdoc.Doc]\xA0=\xA0''"])
['a:\xA0int', '*b', "c:\xA0List[pdoc.Doc]\xA0=\xA0[]"])

# typed, linked
def link(dobj):
return '<a href="{}">{}</a>'.format(dobj.url(relative_to=mod), dobj.qualname)

self.assertEqual(func.params(annotate=True, link=link),
['a:\xA0int', '*b',
"c:\xa0List[<a href=\"#pdoc.Doc\">Doc</a>]\xa0=\xa0''"])
"c:\xa0List[<a href=\"#pdoc.Doc\">Doc</a>]\xa0=\xa0[]"])

def test_Function_return_annotation(self):
import typing

0 comments on commit 43f28dd

Please sign in to comment.
You can’t perform that action at this time.