
Security News
pnpm 10.12 Introduces Global Virtual Store and Expanded Version Catalogs
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.
A decorator for decorators that allows you to see the parameters of a decorated function when using it in PyCharm.
A decorator for decorators that allows you to see the parameters of a decorated function when using it in PyCharm.
PyPi: https://pypi.org/project/decohints/
Below is an example of a decorator with parameters without the use of decohints
:
from functools import wraps
def decorator_with_params(aa=None, bb=None, cc=None):
def _decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
try:
result = func(*args, **kwargs)
except Exception:
print("Error")
return
return result
return wrapper
return _decorator
@decorator_with_params()
def test(a: int, b: int) -> int:
return a + b
If you type below test()
in PyCharm and wait, it will show decorator wrapper parameter hints as test
function
parameter hints:
This is not convenient and can confuse developers, which is why this library was made.
pip install decohints
✅ Works with all kinds of decorators
⚠️ If your decorator is already wrapped in another decorator, thendecohints
should be on top
To use, you need to follow two simple steps:
decohints
decorator from the decohints
library:from decohints import decohints
decohints
decorator:@decohints
def your_decorator():
...
The following is an example of a decorator with parameters, with using decohints
:
from functools import wraps
from decohints import decohints
@decohints
def decorator_with_params(aa=None, bb=None, cc=None):
def _decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
try:
result = func(*args, **kwargs)
except Exception:
print("Error")
return
return result
return wrapper
return _decorator
@decorator_with_params()
def test(a: int, b: int) -> int:
return a + b
If you type below test()
in PyCharm and wait, it will show test
function parameter hints:
❕Examples of use with decorator class, class decorators, and more are found at here: click
✅ Works with all kinds of decorator functions
Specifying the type wrapper: func
will have the same behavior as using decohints
.
Example:
from functools import wraps
def decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
try:
result = func(*args, **kwargs)
except Exception:
print("Error")
return
return result
wrapper: func
return wrapper
@decorator
def test(a: int, b: int) -> int:
return a + b
If you type below test()
in PyCharm and wait, it will show test
function parameter hints:
❗️This method only works in decorator functions with parameters
If you specify the Callable
type from the typing
module for the result of the decorator with parameters, then the
behavior will be the same as using decohints
.
Example:
from functools import wraps
from typing import Callable
def decorator_with_params(aa=None, bb=None, cc=None) -> Callable:
def _decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
try:
result = func(*args, **kwargs)
except Exception:
print("Error")
return
return result
return wrapper
return _decorator
@decorator_with_params()
def test(a: int, b: int) -> int:
return a + b
If you type below test()
in PyCharm and wait, it will show test
function parameter hints:
FAQs
A decorator for decorators that allows you to see the parameters of a decorated function when using it in PyCharm.
We found that decohints demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.
Security News
Amaro 1.0 lays the groundwork for stable TypeScript support in Node.js, bringing official .ts loading closer to reality.
Research
A deceptive PyPI package posing as an Instagram growth tool collects user credentials and sends them to third-party bot services.