Skip to content
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

server: more specific types for decorators #89

Merged
merged 1 commit into from
Jan 27, 2020

Conversation

perrinjerome
Copy link
Contributor

Description

Use a TypeVar so that type checkers understand that the signature is
same as the decorated functions, so that these functions can be
typechecked.

fixes #88

Code review checklist (for code reviewer to complete)

  • Pull request represents a single change (i.e. not fixing disparate/unrelated things in a single PR)
  • Title summarizes what is changing
  • Commit messages are meaningful (see this for details)
  • Tests have been included and/or updated, as appropriate
  • Docstrings have been included and/or updated, as appropriate
  • Standalone docs have been updated accordingly
  • CONTRIBUTORS.md was updated, as appropriate
  • Changelog has been updated, as needed (see CHANGELOG.md)

@danixeee danixeee self-requested a review January 7, 2020 15:46
@danixeee danixeee added the enhancement New feature or request label Jan 7, 2020
Copy link
Contributor

@danixeee danixeee left a comment

Choose a reason for hiding this comment

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

@perrinjerome And thank you again! :)

After we merge #92, please update the changelog.

@perrinjerome
Copy link
Contributor Author

I realised that the @thread needed the same change, otherwise we loose the type when used like this:

@json_server.thread()
@json_server.feature(COMPLETION, trigger_characters=[','])
def completions(params: CompletionParams = None) -> CompletionList:
    """Returns completion items."""
    return CompletionList(False, [
        CompletionItem('"'),
        CompletionItem('['),
        CompletionItem(']'),
        CompletionItem('{'),
        CompletionItem('}')
    ])

I pushed a fixup commit for that.

I'll rebase to squash commits and update changelog once #92 is merged (let me know if you don't like rebase and push force, then I can do with merge)

Use a TypeVar so that type checkers understand that the signature is
same as the decorated functions, so that these functions can be
typechecked.

fixes openlawlibrary#88
@perrinjerome
Copy link
Contributor Author

@danixeee I rebased and updated changelog, please take another look

Copy link
Contributor

@danixeee danixeee left a comment

Choose a reason for hiding this comment

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

Looks good.

@danixeee danixeee merged commit 7873960 into openlawlibrary:master Jan 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feature and command decorators loose type annotations
2 participants