Skip to content

Commit

Permalink
remove some unnecessary format strings
Browse files Browse the repository at this point in the history
  • Loading branch information
mxndtaylor committed Jun 2, 2024
1 parent 2ec1a92 commit e7debce
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
15 changes: 8 additions & 7 deletions src/aliasing/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,15 @@ def attach(
)
if trample_ok:
message += (
f" Overriding with alias for {self._for}."
f" Pass `trample_ok=False` to disallow this behavior."
f" Overriding with alias for {self._for}. Pass"
" `trample_ok=False` to disallow this behavior."
)
warn(message, TrampleAliasWarning)
else:
message += (
f" Cannot override it with alias for {self._for}"
f" by default, pass `trample_ok=True` to override"
f" the member anyway."
f" Cannot override it with alias for {self._for} by"
" default, pass `trample_ok=True` to override the member"
" anyway."
)
raise TrampleAliasError(message)
setattr(cls, name, self)
Expand Down Expand Up @@ -238,8 +238,9 @@ def alias(
name = member.__func__.__name__
else:
raise RuntimeError(
f"could not resolve alias name from non-None, non-str member"
f" {member} without `__name__` attribute"
"could not resolve alias name from non-None, non-str member"
f" {member} without "
"`__name__` attribute"
)

new_alias = alias(
Expand Down
4 changes: 2 additions & 2 deletions src/aliasing/virtual_alias.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ def __set_name__(self, owner: Any, name: str) -> None:
except TrampleAliasWarning as w:
msg = str(w.args[0]).replace(
"Pass `trample_ok=False`",
f"Remove '{alias._name}' from the"
f" `trample_ok` list parameter",
f"Remove '{alias._name}' from the "
"`trample_ok` list parameter",
)
is_warn = True
except TrampleAliasError as e:
Expand Down
6 changes: 3 additions & 3 deletions tests/alias_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def __init__(self):
assert exc_info.value.args[0] == (
f"Owner class {AliasAttachTest.__name__} already has member with name"
f" {alias_name}. Cannot override it with alias for {PROP_NAME} by default,"
f" pass `trample_ok=True` to override the member anyway."
" pass `trample_ok=True` to override the member anyway."
)


Expand All @@ -135,8 +135,8 @@ def __init__(self):
assert issubclass(w[-1].category, TrampleAliasWarning)
assert str(w[-1].message) == (
f"Owner class {AliasAttachTest.__name__} already has member with name"
f" {alias_name}. Overriding with alias for {PROP_NAME}. Pass `trample_ok=False`"
f" to disallow this behavior."
f" {alias_name}. Overriding with alias for {PROP_NAME}. Pass"
" `trample_ok=False` to disallow this behavior."
)


Expand Down
4 changes: 2 additions & 2 deletions tests/aliased_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,8 @@ def method(self):
error = exc_info.value
assert isinstance(error, RuntimeError)
assert error.args[0] == (
f"could not resolve alias name from non-None, non-str"
f" member {bad_alias_target} without `__name__` attribute"
"could not resolve alias name from non-None, non-str"
" member {bad_alias_target} without `__name__` attribute"
)


Expand Down
11 changes: 5 additions & 6 deletions tests/virtual_alias_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def method2(self): ...
f"Owner class {WarningTest.__name__} already has member with name"
f" {WarningTest.method2.__name__}. Overriding with alias for"
f" {WarningTest.method1.__name__}. Remove '{WarningTest.method2.__name__}'"
f" from the `trample_ok` list parameter to disallow this behavior."
" from the `trample_ok` list parameter to disallow this behavior."
)


Expand All @@ -78,9 +78,8 @@ def method2(self): ...

assert isinstance(trample_error, TrampleAliasError)
assert trample_error.args[0] == (
f"Owner class ErrorTest already has member with name"
f" method2. Cannot override it with alias for"
f" method1 by default, pass"
f" `trample_ok=['method2']` to override the member"
f" anyway."
"Owner class ErrorTest already has member with name"
" method2. Cannot override it with alias for"
" method1 by default, pass `trample_ok=['method2']` to override "
"the member anyway."
)

0 comments on commit e7debce

Please sign in to comment.