Skip to content

Mypy plugin for typed decorators #88

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 15, 2019
Merged

Mypy plugin for typed decorators #88

merged 4 commits into from
Jun 15, 2019

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented Jun 14, 2019

from returns.result import safe

@safe
def test() -> int:
    return 1

reveal_type(test)
reveal_type(test())

When running mypy it yields correct results:

» mypy test.py --show-traceback
test.py:7: error: Revealed type is 'def () -> returns.result.Result[builtins.int*, builtins.Exception]'
test.py:8: error: Revealed type is 'returns.result.Result[builtins.int*, builtins.Exception]'

I have not tested it yet, I will need to implement #47 first, but this is huge!
Since I am really annoyed by this issue. I had so many mistakes already in my project because of this limitation.

@sobolevn sobolevn requested a review from proofit404 June 14, 2019 20:00
@sobolevn sobolevn changed the title WIP: first working prototype WIP: first working mypy plugin prototype Jun 14, 2019
Copy link

@proofit404 proofit404 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to move it into returns.contrib.mypy.decorator_plugin.

This is a universal approach other projects has in their naming schema.

Copy link

@proofit404 proofit404 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I strongly suggest using https://github.com/mkurnikov/pytest-mypy-plugins before the merge.

@sobolevn
Copy link
Member Author

@proofit404

I suggest to move it into returns.contrib.mypy.decorator_plugin.

Good idea!

I strongly suggest using https://github.com/mkurnikov/pytest-mypy-plugins before the merge.

Sure! That's what I have mentioned in the PR's body:

I have not tested it yet, I will need to implement #47 first, but this is huge!

@sobolevn sobolevn changed the title WIP: first working mypy plugin prototype Mypy plugin for typed decorators Jun 15, 2019
@sobolevn sobolevn merged commit 8e8e93d into master Jun 15, 2019
@sobolevn sobolevn deleted the issue-87 branch July 1, 2019 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants