Releases: pwwang/python-varname
Releases · pwwang/python-varname
0.8.0 (#63)
Compared to v0.7.3
- Add
UsingExecWarningwhenexecis used to retrievefuncforargname(). - Remove
NonVariableArgumentError. UseImproperUseErrorinstead. - Add
VarnameErrorandVarnameWarningas root for varname-related exceptions and warnings, respectively. - Default
stricttoTrueforvarname(),helpers.register()andhelpers.Wrapper() - Limit number of context lines for showing where
ImproperUseErrorhappens
Compared to v0.7.0
- Add
UsingExecWarningwhenexecis used to retrievefuncforargname(). - Remove
NonVariableArgumentError. UseImproperUseErrorinstead. - Add
VarnameErrorandVarnameWarningas root for varname-related exceptions and warnings, respectively. - Add
strictmode tovarname(),helpers.register()andhelpers.Wrapper()(#57) - Support the walrus operator (
:=) (#58) - Change
argname()to accept argument names instead of arguments themselves - Remove
pos_onlyargument fromargname() - Add
ignoreargument toargname()to ignore intermediate frames - Limit
VarnameRetrievingErrorto the situations only when the AST node is not able to be retrieved.
0.7.3
0.7.2 (#59)
0.7.1: Add `ignore` argument to `argname2()` (#55)
- Add
ignoreargument toargname2() - Fix Fix utils.get_argument_sources() when kwargs is given as
**kwargs.
0.7.0 (#54)
0.6.5 (#52)
- Add
separgument tohelpers.debug()
0.6.4 (#50)
- Add ImproperUseError to distinguish node retrieving error from improper varname use #49
0.6.3
0.6.2: Using argname to reimplement nameof (#44)
- Remove argument
fullfornameof, usevars_onlyinstead. Whenvars_only=False, source of the argument returned.# before: nameof(a.b, full=True) # 'a.b' nameof(x[0], full=True) # unable to fetch # after (requires asttoken): nameof(a.b, vars_only=False) # 'a.b' nameof(x[0], vars_only=False) # 'x[0]'
- Add argument
frametoargname, so that it can be wrapped.def argname2(arg, *more_args): return argname(arg, *more_args, frame=2)
- Allow
argnameto fetch the source of variable keyword arguments (**kwargs), which will be an empty dict ({}) when no keyword arguments passed.def func(a, **kwargs): return argname(a, kwargs) # before: func(x) # raises error # after: func(x) # returns ('x', {})
- Add argument
pos_onlytoargnameto only match the positional arguments# before def func(a, b=1): return argname(a) func(x) # 'x' func(x, b=2) # error since 2 is not ast.Name # after def func(a, b=1): return argname(a, pos_only=True) func(x) # 'x' func(x, b=2) # 'x'
- Parse the arguments only if needed
# before def func(a, b): return argname(a) func(x, 1) # NonVariableArgumentError # after func(x, 1) # 'x'
- Allow variable positional arguments for
argnameso thatargname(*args)is allowed# before def func(arg, *args): return argname(arg, args) # *args not allowed x = y = 1 func(x, y) # ('x', ('y', 1)) # after def func(arg, *args): return argname(arg, *args) x = y = 1 func(x, y) # ('x', 'y')
- Add
vars_only(defaults toFalse) argument tohelpers.debugso source of expression becomes availablea=1 debug(a+a) # DEBUG: a+a=2