Closed
Description
-
Are you reporting a bug, or opening a feature request?
It's a newbie question. -
Please insert below the code you are checking with mypy
foo.py
class Person(object):
def __init__(self, name, age, is_male):
# type: (str, int, bool) -> None
self.name = name
self.age = age
self.is_male = is_male
def greeting(self):
# type: () -> None
print "Hello, " + self.name
def init():
__builtins__["Person"] = Person
bar.py
from foo import init
init()
alice = Person("Alice", 99, False)
alice.greeting()
- What is the actual behavior/output?
$ mypy --py2 bar.py foo.py
bar.py:7: error: Name 'Person' is not defined
Found 1 error in 1 file (checked 2 source files)
I defined a class named Person
and added it into __builtins__
, but mypy could not recognize it. I wonder what I can do to make it work. Thank you.
Metadata
Metadata
Assignees
Labels
No labels