Skip to content

Update extending_mypy.rst #10222

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 1 commit into from
Apr 11, 2021
Merged

Update extending_mypy.rst #10222

merged 1 commit into from
Apr 11, 2021

Conversation

sobolevn
Copy link
Member

Two things I have changed:

  1. get_function_signature_hook was missing from docs, but it is defined

    mypy/mypy/plugin.py

    Lines 368 to 376 in ac66403

    # A context for a function signature hook that infers a better signature for a
    # function. Note that argument types aren't available yet. If you need them,
    # you have to use a method hook instead.
    FunctionSigContext = NamedTuple(
    'FunctionSigContext', [
    ('args', List[List[Expression]]), # Actual expressions for each formal argument
    ('default_signature', CallableType), # Original signature of the method
    ('context', Context), # Relevant location context (e.g. for error messages)
    ('api', CheckerPluginInterface)])
  2. While reading the docs, this UserDefined for get_class_decorator_hook example caught my eye. It was not clear how UserDefined and @customize work. I believe that @dataclass example is better for two reasons. First, it is an existing API and is already familiar to our users. Secondly, there's an actual plugin for it, so people can see how it is implemented

Refs #6760

Two things I have changed:
1. `get_function_signature_hook` was missing from docs, but it is defined https://github.com/python/mypy/blob/ac66403cb4374b858786350b96e7f5972db84bcd/mypy/plugin.py#L368-L376
2. While reading the docs, this `UserDefined` for `get_class_decorator_hook` example caught my eye. It was not clear how `UserDefined` and `@customize` work. I believe that `@dataclass` example is better for two reasons. First, it is an existing API and is already familiar to our users. Secondly, there's an actual plugin for it, so people can see how it is implemented
@JelleZijlstra JelleZijlstra merged commit 6fc5f38 into python:master Apr 11, 2021
@JelleZijlstra
Copy link
Member

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants