Skip to content

Commit

Permalink
Reproduce #91
Browse files Browse the repository at this point in the history
  • Loading branch information
kedder committed Mar 13, 2023
1 parent 6945ee0 commit 478fcce
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions mypy-zope.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[mypy]
namespace_packages=True
warn_unreachable=True
plugins=mypy_zope:plugin
29 changes: 29 additions & 0 deletions tests/samples/isinstance_impl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from typing import Optional
from zope.interface import implementer, Interface


class IFoo(Interface):
...


@implementer(IFoo)
class MyFoo:
...


def make_foo() -> Optional[IFoo]:
return MyFoo()


x = make_foo()
reveal_type(x)
assert isinstance(x, MyFoo)

# The code below should not be considered unreachable
print("hello")

"""
<output>
isinstance_impl.py:19: note: Revealed type is "Union[__main__.IFoo, None]"
</output>
"""
1 change: 1 addition & 0 deletions tests/test_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def test_samples(samplefile, mypy_cache_dir):
opts.show_traceback = True
opts.namespace_packages = True
opts.hide_error_codes = True
opts.warn_unreachable = True
opts.plugins = ['mypy_zope:plugin']
# Config file is needed to load plugins, it doesn't not exist and is not
# supposed to.
Expand Down

0 comments on commit 478fcce

Please sign in to comment.