You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Based on my experience with Hypothesis (especially the builds() strategy), I'd suggest that attrs should instead leave users with
x=attr.ib(factory=lambda: logger.new(foo="bar"))
(though you might want to add some documentation suggesting this, or functools.partial)
Passing through arbitrary args and kwargs can cause a variety of problems. The main two for this case are that attr.Factory already has named arguments - so users cannot provide arguments with those names to a callable factory - and takes_self is in some ways worse (impossible to provide star-args without explicitly passing a value for takes_self positionally). Using named args=(), kw_args=None arguments and dealing with the None-to-dict() issue would work, but IMO it's screamingly ugly and the lambda-or-partial solution works just fine.
useful e.g. with structlog
The text was updated successfully, but these errors were encountered: