diff options
Diffstat (limited to 'qutebrowser/utils/utils.py')
-rw-r--r-- | qutebrowser/utils/utils.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/qutebrowser/utils/utils.py b/qutebrowser/utils/utils.py index a56769255..9c68932f3 100644 --- a/qutebrowser/utils/utils.py +++ b/qutebrowser/utils/utils.py @@ -382,7 +382,7 @@ def get_repr(obj: Any, constructor: bool = False, **attrs: Any) -> str: obj: The object to get a repr for. constructor: If True, show the Foo(one=1, two=2) form instead of <Foo one=1 two=2>. - attrs: The attributes to add. + **attrs: The attributes to add. """ cls = qualname(obj.__class__) parts = [] @@ -391,11 +391,10 @@ def get_repr(obj: Any, constructor: bool = False, **attrs: Any) -> str: parts.append('{}={!r}'.format(name, val)) if constructor: return '{}({})'.format(cls, ', '.join(parts)) + elif parts: + return '<{} {}>'.format(cls, ' '.join(parts)) else: - if parts: - return '<{} {}>'.format(cls, ' '.join(parts)) - else: - return '<{}>'.format(cls) + return '<{}>'.format(cls) def qualname(obj: Any) -> str: @@ -669,11 +668,12 @@ def yaml_load(f: Union[str, IO[str]]) -> Any: r"of from 'collections\.abc' is deprecated.*"): try: data = yaml.load(f, Loader=YamlLoader) - except ValueError as e: - if str(e).startswith('could not convert string to float'): + except ValueError as e: # pragma: no cover + pyyaml_error = 'could not convert string to float' + if str(e).startswith(pyyaml_error): # WORKAROUND for https://github.com/yaml/pyyaml/issues/168 raise yaml.YAMLError(e) - raise # pragma: no cover + raise end = datetime.datetime.now() |