Skip to content

Conversation

@tomschr
Copy link
Contributor

@tomschr tomschr commented Nov 21, 2022

Situation

The documentation shows an example in the "Decorator factories" section and it looks like this:

# Implementation
def atomic(__func: Callable[..., Any] = None, *, savepoint: bool = True):
    # pruned

However, if you save the file and run mypy, it complains about the previous line:

error: Incompatible default for argument "__func" (default has type "None", argument has type "Callable[..., Any]")  [assignment]
note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True

Proposed change

This change adds Optional around Callable[..., Any]] which avoids the above error message.

mypy complains about

  error: Incompatible default for argument "__func" (default has type "None", argument has type "Callable[..., Any]")  [assignment]
  note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True

This change adds Optional around "Callable[..., Any]] = None"
Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

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

Nice, thanks for the fix!

@hauntsaninja hauntsaninja merged commit c660354 into python:master Nov 21, 2022
@tomschr tomschr deleted the patch-1 branch November 21, 2022 08:03
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