Skip to content

Update the signature of decorator.decorator#3336

Merged
JukkaL merged 1 commit intopython:masterfrom
JukkaL:decorator
Oct 10, 2019
Merged

Update the signature of decorator.decorator#3336
JukkaL merged 1 commit intopython:masterfrom
JukkaL:decorator

Conversation

@JukkaL
Copy link
Contributor

@JukkaL JukkaL commented Oct 10, 2019

Nothing prevents a decorator defined using @decorator from
changing the signature of the decorated function. For example,
this example changes the return type to str:

from decorator import decorator

@decorator
def stringify(f, *args, **kwargs) -> str:
    return str(f(*args, **kwargs))

The old signature caused false positives in internal Dropbox code.

I couldn't come up with a signature that would produce better types
with mypy while not generating false positives.

Nothing prevents a decorator defined using `@decorator` from
changing the signature of the decorated function. For example,
this example changes the return type to `str`:

```
from decorator import decorator

@decorator
def stringify(f, *args, **kwargs) -> str:
    return str(f(*args, **kwargs))
```

The old signature caused false positives in internal Dropbox code.

I couldn't come up with a signature that would produce better types
with mypy while not generating false positives.
Copy link
Member

@ilevkivskyi ilevkivskyi left a comment

Choose a reason for hiding this comment

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

OK

@JukkaL JukkaL merged commit eca9375 into python:master Oct 10, 2019
@JukkaL JukkaL deleted the decorator branch October 10, 2019 15:45
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