Closed
Description
I'm adding MyPy annotations to a single Python 2 file that uses the py2neo
package, here's what I have so far (just 2 functions annotated). The file is called gdb.py
.
from py2neo import Graph
from contexttimer import Timer
import simpleflake
from datetime import datetime
graph = None
def init(neo4j_uri):
# type: (str) -> None
global graph
graph = Graph('{}/db/data'.format(neo4j_uri))
def _exec(cypher_text, params):
# type: (str, Dict[str,Any]) -> Tuple[RecordListList,Timer]
with Timer() as t:
result = graph.cypher.execute( cypher_text, params )
return result, t
I run MyPy from the terminal in the same directory and virtual-environment as normal Python > mypy --py2 gdb.py
I get this error output:
fugu_gdb.py:15: error: Cannot find module named 'py2neo'
fugu_gdb.py:15: note: (Perhaps setting MYPYPATH would help)
fugu_gdb.py:16: error: Cannot find module named 'contexttimer'
fugu_gdb.py:17: error: Cannot find module named 'simpleflake'
fugu_gdb.py: note: In function "_exec":
fugu_gdb.py:34: error: Name 'RecordListList' is not defined
I can't find any documentation on how MYPYPATH
is meant to be set.
My __init__.py
file doesn't contain anything of significance, just futures imports.
Python itself works fine - python gdb.py
runs without any errors when run from the same terminal session as mypy
.
Metadata
Metadata
Assignees
Labels
No labels