(val)
| 3928 | if v.annotation is not inspect.Signature.empty else '' |
| 3929 | |
| 3930 | def default_val_str(val): |
| 3931 | if isinstance(val, (tuple, list)): |
| 3932 | str_pieces = ['(' if isinstance(val, tuple) else '['] |
| 3933 | str_pieces.append(', '.join(default_val_str(v) for v in val)) |
| 3934 | if isinstance(val, tuple) and len(str_pieces) == 2: |
| 3935 | str_pieces.append(',') |
| 3936 | str_pieces.append(')' if isinstance(val, tuple) else ']') |
| 3937 | return ''.join(str_pieces) |
| 3938 | |
| 3939 | # Need to fix up some default value strings. |
| 3940 | # First case: modules. Default module `repr` contains the FS path of the module. |
| 3941 | # Don't leak that |
| 3942 | if isinstance(val, types.ModuleType): |
| 3943 | return f'<module {val.__name__}>' |
| 3944 | |
| 3945 | # Second case: callables. Callables (such as lambdas) encode their address in |
| 3946 | # their string repr. Don't do that |
| 3947 | if callable(val): |
| 3948 | return f'<function {val.__name__}>' |
| 3949 | |
| 3950 | return str(val) |
| 3951 | |
| 3952 | if v.default is not inspect.Signature.empty: |
| 3953 | default_val_str = default_val_str(v.default) if not isinstance(v.default, str) else f"'{v.default}'" |
nothing calls this directly
no test coverage detected