Skip to content

Commit

Permalink
Update documentation to include PartialCallableObjectProxy
Browse files Browse the repository at this point in the history
  • Loading branch information
Neil Wadhvana committed Dec 5, 2024
1 parent 0da4ba5 commit ca2ffc4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions blog/05-decorators-which-accept-arguments.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ the above recipe to:
```python
def optional_arguments(wrapped=None, arg=1):
if wrapped is None:
return functools.partial(optional_arguments, arg=arg)
return PartialCallableObjectProxy(optional_arguments, arg=arg)

@decorator
def _wrapper(wrapped, instance, args, kwargs):
Expand Down Expand Up @@ -185,7 +185,7 @@ only argument syntax.
```python
def optional_arguments(wrapped=None, *, arg=1):
if wrapped is None:
return functools.partial(optional_arguments, arg=arg)
return PartialCallableObjectProxy(optional_arguments, arg=arg)

@decorator
def _wrapper(wrapped, instance, args, kwargs):
Expand All @@ -199,6 +199,12 @@ decorator argument as the positional argument for wrapped. For consistency,
keyword only arguments can also be enforced for required arguments even
though it isn't strictly necessary.

The `PartialCallableObjectProxy` object is an implementation of
`functools.partial()` which uses wrapt and preserves introspection for the
wrapped callable object. This means you'll get better introspection
capabilities when examining the decorated object in a code editor, which can
be particularly useful.

```python
def required_arguments(*, arg):
@decorator
Expand Down

0 comments on commit ca2ffc4

Please sign in to comment.