Skip to content

Commit

Permalink
Simplify a couple of unnecessary/unclear f-string conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
benhoyt committed Jan 16, 2023
1 parent 644df27 commit 469982b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions ops/framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def __init__(self, parent: Optional[Union['Handle', 'Object']], kind: str, key:
if key:
self._path = f"{kind}[{key}]"
else:
self._path = f"{kind}"
self._path = kind

def nest(self, kind: str, key: str) -> 'Handle':
"""Create a new handle as child of the current one."""
Expand Down Expand Up @@ -507,7 +507,7 @@ class PrefixedEvents:

def __init__(self, emitter: Object, key: str):
self._emitter = emitter
self._prefix = f"{key.replace('-', '_')}_"
self._prefix = key.replace('-', '_') + '_'

def __getattr__(self, name: str) -> BoundEvent[Any]:
return getattr(self._emitter, self._prefix + name)
Expand Down
2 changes: 1 addition & 1 deletion ops/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1646,7 +1646,7 @@ def __iter__(self):

def __getitem__(self, storage_name: str) -> List['Storage']:
if storage_name not in self._storage_map:
meant = ', or '.join([f'{k!r}' for k in self._storage_map.keys()])
meant = ', or '.join(repr(k) for k in self._storage_map.keys())
raise KeyError(
f'Storage {storage_name!r} not found. Did you mean {meant}?')
storage_list = self._storage_map[storage_name]
Expand Down
4 changes: 2 additions & 2 deletions test/test_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,14 @@ def test_long_string_logging(self):
with patch('sys.stderr', buffer):
ops.log.setup_root_logging(self.backend, debug=True)
logger = logging.getLogger()
logger.debug(f"{'l' * MAX_LOG_LINE_LEN}")
logger.debug('l' * MAX_LOG_LINE_LEN)

self.assertEqual(len(self.backend.calls()), 1)

self.backend.calls(clear=True)

with patch('sys.stderr', buffer):
logger.debug(f"{'l' * (MAX_LOG_LINE_LEN + 9)}")
logger.debug('l' * (MAX_LOG_LINE_LEN + 9))

calls = self.backend.calls()
self.assertEqual(len(calls), 3)
Expand Down

0 comments on commit 469982b

Please sign in to comment.