Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inspect.param.empty is a class and can be used as singleton. Related #35 #36

Merged
merged 1 commit into from Aug 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion logwrap/__init__.py
Expand Up @@ -56,7 +56,7 @@
'bind_args_kwargs'
)

__version__ = '4.0.1'
__version__ = '4.0.2'
__author__ = "Alexey Stepanov"
__author_email__ = 'penguinolog@gmail.com'
__maintainers__ = {
Expand Down
6 changes: 3 additions & 3 deletions logwrap/_log_wrap_shared.py
Expand Up @@ -170,7 +170,7 @@ def __str__(self):
as_str += ': {annotation!s}'.format(annotation=formatannotation(self.annotation))

value = self.value
if self.empty == value:
if self.empty is value:
if self.VAR_POSITIONAL == self.kind:
value = ()
elif self.VAR_KEYWORD == self.kind:
Expand Down Expand Up @@ -551,7 +551,7 @@ def _get_func_args_repr(
else:
value = param.value

if param.empty == value:
if param.empty is value:
if param.VAR_POSITIONAL == param.kind:
value = ()
elif param.VAR_KEYWORD == param.kind:
Expand All @@ -570,7 +570,7 @@ def _get_func_args_repr(
param_str += comment(kind=param.kind)
last_kind = param.kind

if param.empty == param.annotation:
if param.empty is param.annotation:
annotation = ""
else:
annotation = " # type: {param.annotation!s}".format(param=param)
Expand Down
8 changes: 4 additions & 4 deletions logwrap/_repr_utils.py
Expand Up @@ -532,9 +532,9 @@ def _repr_callable(
indent=self.next_indent(indent),
param=param
)
if param.annotation != param.empty:
if param.annotation is not param.empty:
param_str += ': {param.annotation}'.format(param=param)
if param.value != param.empty:
if param.value is not param.empty:
param_str += '={val}'.format(
val=self.process_element(
src=param.value,
Expand All @@ -548,7 +548,7 @@ def _repr_callable(
param_str += "\n" + " " * indent

sig = signature(src)
annotation = '' if sig.return_annotation == Parameter.empty else ' -> {sig.return_annotation!r}'.format(sig=sig)
annotation = '' if sig.return_annotation is Parameter.empty else ' -> {sig.return_annotation!r}'.format(sig=sig)

return "\n{spc:<{indent}}<{obj!r} with interface ({args}){annotation}>".format(
spc="",
Expand Down Expand Up @@ -724,7 +724,7 @@ def _repr_callable(
param_str += "\n" + " " * indent

sig = signature(src)
annotation = '' if sig.return_annotation == Parameter.empty else ' -> {sig.return_annotation!r}'.format(sig=sig)
annotation = '' if sig.return_annotation is Parameter.empty else ' -> {sig.return_annotation!r}'.format(sig=sig)

return "\n{spc:<{indent}}<{obj!s} with interface ({args}){annotation}>".format(
spc="",
Expand Down