-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Description
- Are you reporting a bug, or opening a feature request?
There's a bug when working with TypeQuery
. It is literally unusable.
- Please insert below the code you are checking with mypy,
or a mock-up repro if the source is private. We would appreciate
if you try to simplify your case to a minimal repro.
Just take any type inside a plugin and pass it to TypeQuery
:
from mypy.plugin import FunctionContext
from mypy.types import Type as MypyType
from mypy.types import TypeQuery
from mypy.plugin import Plugin
def analyze(ctx: FunctionContext) -> MypyType:
print(ctx.default_return_type.accept(TypeQuery(any)))
return ctx.default_return_type
class _ReturnsPlugin(Plugin):
def get_function_hook(self, fullname):
if fullname == 'ex.test':
return analyze
def plugin(version: str):
return _ReturnsPlugin
And provide any source code to trigger this plugin:
# ex.py
def test() -> int:
return 1
- What is the actual behavior/output?
» PYTHONFAULTHANDLER=1 mypy ex.py
Fatal Python error: Segmentation fault
Current thread 0x0000000100b155c0 (most recent call first):
File "/Users/sobolev/Documents/github/returns/returns/contrib/mypy/_features/decorators.py", line 18 in analyze
File "/Users/sobolev/Documents/github/returns/.venv/lib/python3.7/site-packages/mypy/__main__.py", line 8 in console_entry
File "/Users/sobolev/Documents/github/returns/.venv/bin/mypy", line 10 in <module>
[1] 22569 segmentation fault PYTHONFAULTHANDLER=1 mypy ex.py
- What is the behavior/output you expect?
I would expect TypeQuery
to work. Without the segfault.
- What are the versions of mypy and Python you are using?
Do you see the same issue after installing mypy from Git master?
0.780
- What are the mypy flags you are using? (For example --strict-optional)
Full list: https://github.com/dry-python/returns/blob/master/setup.cfg#L122
Metadata
Metadata
Assignees
Labels
No labels