Improve string formatting v6 (#33698)

This commit is contained in:
springstan 2020-04-07 23:14:28 +02:00 committed by GitHub
parent d7e3b0b755
commit eae21be5b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
43 changed files with 81 additions and 87 deletions

View File

@ -86,7 +86,7 @@ SET_ZONE_OVERRIDE_SCHEMA = vol.Schema(
vol.Coerce(float), vol.Range(min=4.0, max=35.0)
),
vol.Optional(ATTR_DURATION_UNTIL): vol.All(
cv.time_period, vol.Range(min=timedelta(days=0), max=timedelta(days=1)),
cv.time_period, vol.Range(min=timedelta(days=0), max=timedelta(days=1))
),
}
)
@ -121,7 +121,7 @@ def convert_dict(dictionary: Dict[str, Any]) -> Dict[str, Any]:
"""Convert a string to snake_case."""
string = re.sub(r"[\-\.\s]", "_", str(key))
return (string[0]).lower() + re.sub(
r"[A-Z]", lambda matched: "_" + matched.group(0).lower(), string[1:]
r"[A-Z]", lambda matched: f"_{matched.group(0).lower()}", string[1:]
)
return {

View File

@ -321,7 +321,7 @@ class GoogleTravelTimeSensor(Entity):
def _get_location_from_attributes(entity):
"""Get the lat/long string from an entities attributes."""
attr = entity.attributes
return "{},{}".format(attr.get(ATTR_LATITUDE), attr.get(ATTR_LONGITUDE))
return f"{attr.get(ATTR_LATITUDE)},{attr.get(ATTR_LONGITUDE)}"
def _resolve_zone(self, friendly_name):
entities = self._hass.states.all()

View File

@ -100,7 +100,7 @@ class NestFlowHandler(config_entries.ConfigFlow):
with async_timeout.timeout(10):
tokens = await flow["convert_code"](user_input["code"])
return self._entry_from_tokens(
"Nest (via {})".format(flow["name"]), flow, tokens
f"Nest (via {flow['name']})", flow, tokens
)
except asyncio.TimeoutError:

View File

@ -203,6 +203,6 @@ class NestTempSensor(NestSensorDevice):
if isinstance(temp, tuple):
low, high = temp
self._state = "{}-{}".format(int(low), int(high))
self._state = f"{int(low)}-{int(high)}"
else:
self._state = round(temp, 1)

View File

@ -28,7 +28,7 @@ class LeafPluggedInSensor(LeafEntity, BinarySensorDevice):
@property
def name(self):
"""Sensor name."""
return "{} {}".format(self.car.leaf.nickname, "Plug Status")
return f"{self.car.leaf.nickname} Plug Status"
@property
def is_on(self):
@ -49,7 +49,7 @@ class LeafChargingSensor(LeafEntity, BinarySensorDevice):
@property
def name(self):
"""Sensor name."""
return "{} {}".format(self.car.leaf.nickname, "Charging Status")
return f"{self.car.leaf.nickname} Charging Status"
@property
def is_on(self):

View File

@ -27,7 +27,7 @@ class LeafClimateSwitch(LeafEntity, ToggleEntity):
@property
def name(self):
"""Switch name."""
return "{} {}".format(self.car.leaf.nickname, "Climate Control")
return f"{self.car.leaf.nickname} Climate Control"
def log_registration(self):
"""Log registration."""

View File

@ -109,7 +109,7 @@ class NmapDeviceScanner(DeviceScanner):
last_results = []
exclude_hosts = self.exclude
if exclude_hosts:
options += " --exclude {}".format(",".join(exclude_hosts))
options += f" --exclude {','.join(exclude_hosts)}"
try:
result = scanner.scan(hosts=" ".join(self.hosts), arguments=options)

View File

@ -159,8 +159,8 @@ class NMBSLiveBoard(Entity):
next_departure = liveboard["departures"]["departure"][0]
self._attrs = next_departure
self._state = "Track {} - {}".format(
next_departure["platform"], next_departure["station"]
self._state = (
f"Track {next_departure['platform']} - {next_departure['station']}"
)

View File

@ -83,7 +83,7 @@ async def _update_no_ip(hass, session, domain, auth_str, timeout):
params = {"hostname": domain}
headers = {
AUTHORIZATION: "Basic {}".format(auth_str.decode("utf-8")),
AUTHORIZATION: f"Basic {auth_str.decode('utf-8')}",
USER_AGENT: HA_USER_AGENT,
}

View File

@ -254,9 +254,7 @@ class NotionEntity(Entity):
@property
def name(self):
"""Return the name of the sensor."""
return "{}: {}".format(
self._notion.sensors[self._sensor_id]["name"], self._name
)
return f"{self._notion.sensors[self._sensor_id]['name']}: {self._name}"
@property
def should_poll(self):
@ -267,7 +265,7 @@ class NotionEntity(Entity):
def unique_id(self):
"""Return a unique, unchanging string that represents this sensor."""
task = self._notion.tasks[self._task_id]
return "{}_{}".format(self._sensor_id, task["task_type"])
return f"{self._sensor_id}_{task['task_type']}"
async def _update_bridge_id(self):
"""Update the entity's bridge ID if it has changed.

View File

@ -122,7 +122,7 @@ class NUTSensor(Entity):
self._firmware = firmware
self._model = model
self._device_name = name
self._name = "{} {}".format(name, SENSOR_TYPES[sensor_type][0])
self._name = f"{name} {SENSOR_TYPES[sensor_type][0]}"
self._unit = SENSOR_TYPES[sensor_type][1]
self._state = None
self._unique_id = unique_id

View File

@ -145,8 +145,9 @@ def setup(hass, config):
for printer in config[DOMAIN]:
name = printer[CONF_NAME]
ssl = "s" if printer[CONF_SSL] else ""
base_url = "http{}://{}:{}{}api/".format(
ssl, printer[CONF_HOST], printer[CONF_PORT], printer[CONF_PATH]
base_url = (
f"http{ssl}://{printer[CONF_HOST]}:{printer[CONF_PORT]}"
f"{printer[CONF_PATH]}api/"
)
api_key = printer[CONF_API_KEY]
number_of_tools = printer[CONF_NUMBER_OF_TOOLS]

View File

@ -91,7 +91,7 @@ class OctoPrintSensor(Entity):
if tool is None:
self._name = f"{sensor_name} {condition}"
else:
self._name = "{} {} {} {}".format(sensor_name, condition, tool, "temp")
self._name = f"{sensor_name} {condition} {tool} temp"
self.sensor_type = sensor_type
self.api = api
self._state = None

View File

@ -183,7 +183,7 @@ class ONVIFHassCamera(Camera):
self._port,
self._username,
self._password,
"{}/wsdl/".format(os.path.dirname(onvif.__file__)),
f"{os.path.dirname(onvif.__file__)}/wsdl/",
transport=transport,
)

View File

@ -86,7 +86,7 @@ class OpenAlprCloudEntity(ImageProcessingAlprEntity):
if name:
self._name = name
else:
self._name = "OpenAlpr {}".format(split_entity_id(camera_entity)[1])
self._name = f"OpenAlpr {split_entity_id(camera_entity)[1]}"
@property
def confidence(self):

View File

@ -161,7 +161,7 @@ class OpenAlprLocalEntity(ImageProcessingAlprEntity):
if name:
self._name = name
else:
self._name = "OpenAlpr {}".format(split_entity_id(camera_entity)[1])
self._name = f"OpenAlpr {split_entity_id(camera_entity)[1]}"
@property
def confidence(self):

View File

@ -75,9 +75,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
def _create_processor_from_config(hass, camera_entity, config):
"""Create an OpenCV processor from configuration."""
classifier_config = config.get(CONF_CLASSIFIER)
name = "{} {}".format(
config[CONF_NAME], split_entity_id(camera_entity)[1].replace("_", " ")
)
name = f"{config[CONF_NAME]} {split_entity_id(camera_entity)[1].replace('_', ' ')}"
processor = OpenCVImageProcessor(hass, camera_entity, name, classifier_config)
@ -132,7 +130,7 @@ class OpenCVImageProcessor(ImageProcessingEntity):
if name:
self._name = name
else:
self._name = "OpenCV {}".format(split_entity_id(camera_entity)[1])
self._name = f"OpenCV {split_entity_id(camera_entity)[1]}"
self._classifiers = classifiers
self._matches = {}
self._total_matches = 0

View File

@ -79,8 +79,9 @@ class OpenGarageCover(CoverDevice):
def __init__(self, args):
"""Initialize the cover."""
self.opengarage_url = "{}://{}:{}".format(
"https" if args[CONF_SSL] else "http", args[CONF_HOST], args[CONF_PORT]
self.opengarage_url = (
f"http{'s' if args[CONF_SSL] else ''}://"
f"{args[CONF_HOST]}:{args[CONF_PORT]}"
)
self._name = args[CONF_NAME]
self._device_key = args[CONF_DEVICE_KEY]

View File

@ -125,8 +125,9 @@ class OpenHardwareMonitorData:
def refresh(self):
"""Download and parse JSON from OHM."""
data_url = "http://{}:{}/data.json".format(
self._config.get(CONF_HOST), self._config.get(CONF_PORT)
data_url = (
f"http://{self._config.get(CONF_HOST)}:"
f"{self._config.get(CONF_PORT)}/data.json"
)
try:

View File

@ -82,9 +82,9 @@ async def async_setup(hass, config):
conf = config[DOMAIN]
identifier = "{}, {}".format(
conf.get(CONF_LATITUDE, hass.config.latitude),
conf.get(CONF_LONGITUDE, hass.config.longitude),
identifier = (
f"{conf.get(CONF_LATITUDE, hass.config.latitude)}, "
f"{conf.get(CONF_LONGITUDE, hass.config.longitude)}"
)
if identifier in configured_instances(hass):
return True

View File

@ -20,10 +20,8 @@ from .const import DOMAIN
def configured_instances(hass):
"""Return a set of configured OpenUV instances."""
return {
"{}, {}".format(
entry.data.get(CONF_LATITUDE, hass.config.latitude),
entry.data.get(CONF_LONGITUDE, hass.config.longitude),
)
f"{entry.data.get(CONF_LATITUDE, hass.config.latitude)}, "
f"{entry.data.get(CONF_LONGITUDE, hass.config.longitude)}"
for entry in hass.config_entries.async_entries(DOMAIN)
}
@ -60,9 +58,9 @@ class OpenUvFlowHandler(config_entries.ConfigFlow):
if not user_input:
return await self._show_form()
identifier = "{}, {}".format(
user_input.get(CONF_LATITUDE, self.hass.config.latitude),
user_input.get(CONF_LONGITUDE, self.hass.config.longitude),
identifier = (
f"{user_input.get(CONF_LATITUDE, self.hass.config.latitude)}, "
f"{user_input.get(CONF_LONGITUDE, self.hass.config.longitude)}"
)
if identifier in configured_instances(self.hass):
return await self._show_form({CONF_LATITUDE: "identifier_exists"})

View File

@ -53,7 +53,7 @@ def repr_helper(inp: Any) -> str:
"""Help creating a more readable string representation of objects."""
if isinstance(inp, (dict, MappingProxyType)):
return ", ".join(
repr_helper(key) + "=" + repr_helper(item) for key, item in inp.items()
f"{repr_helper(key)}={repr_helper(item)}" for key, item in inp.items()
)
if isinstance(inp, datetime):
return as_local(inp).isoformat()

View File

@ -64,10 +64,7 @@ async def _create_august_with_devices(
if api_call_side_effects is None:
api_call_side_effects = {}
device_data = {
"doorbells": [],
"locks": [],
}
device_data = {"doorbells": [], "locks": []}
for device in devices:
if isinstance(device, LockDetail):
device_data["locks"].append(
@ -212,7 +209,7 @@ def _mock_august_doorbell_data(deviceid="mockdeviceid1", houseid="mockhouseid1")
return {
"_id": deviceid,
"DeviceID": deviceid,
"name": deviceid + " Name",
"name": f"{deviceid} Name",
"HouseID": houseid,
"UserType": "owner",
"serialNumber": "mockserial",
@ -232,7 +229,7 @@ def _mock_august_lock_data(lockid="mocklockid1", houseid="mockhouseid1"):
return {
"_id": lockid,
"LockID": lockid,
"LockName": lockid + " Name",
"LockName": f"{lockid} Name",
"HouseID": houseid,
"UserType": "owner",
"SerialNumber": "mockserial",

View File

@ -28,7 +28,7 @@ def calls(hass):
def get_switch_name(number):
"""Get a mock switch name."""
return "Mock Switch #" + str(number)
return f"Mock Switch #{number}"
@pytest.fixture

View File

@ -289,7 +289,7 @@ async def test_reachable_for_state(hass_hue, hue_client, state, is_reachable):
async def test_discover_full_state(hue_client):
"""Test the discovery of full state."""
result = await hue_client.get("/api/" + HUE_API_USERNAME)
result = await hue_client.get(f"/api/{HUE_API_USERNAME}")
assert result.status == 200
assert "application/json" in result.headers["content-type"]

View File

@ -285,7 +285,7 @@ class TestComponentsGroup(unittest.TestCase):
group_conf = OrderedDict()
group_conf["second_group"] = {
"entities": "light.Bowl, " + test_group.entity_id,
"entities": f"light.Bowl, {test_group.entity_id}",
"icon": "mdi:work",
}
group_conf["test_group"] = "hello.world,sensor.happy"

View File

@ -110,7 +110,7 @@ class TestHDDTempSensor(unittest.TestCase):
)
assert (
state.attributes.get("friendly_name")
== "HD Temperature " + reference["device"]
== f"HD Temperature {reference['device']}"
)
@patch("telnetlib.Telnet", new=TelnetMock)
@ -123,7 +123,7 @@ class TestHDDTempSensor(unittest.TestCase):
reference = self.reference[state.attributes.get("device")]
assert state.attributes.get("friendly_name") == "FooBar " + reference["device"]
assert state.attributes.get("friendly_name") == f"FooBar {reference['device']}"
@patch("telnetlib.Telnet", new=TelnetMock)
def test_hddtemp_one_disk(self):
@ -143,7 +143,7 @@ class TestHDDTempSensor(unittest.TestCase):
)
assert (
state.attributes.get("friendly_name")
== "HD Temperature " + reference["device"]
== f"HD Temperature {reference['device']}"
)
@patch("telnetlib.Telnet", new=TelnetMock)
@ -179,7 +179,7 @@ class TestHDDTempSensor(unittest.TestCase):
)
assert (
state.attributes.get("friendly_name")
== "HD Temperature " + reference["device"]
== f"HD Temperature {reference['device']}"
)
@patch("telnetlib.Telnet", new=TelnetMock)

View File

@ -666,7 +666,7 @@ class TestInfluxDB(unittest.TestCase):
state = mock.MagicMock(
state=1,
domain=comp["domain"],
entity_id=comp["domain"] + "." + comp["id"],
entity_id=f"{comp['domain']}.{comp['id']}",
object_id=comp["id"],
attributes={},
)

View File

@ -31,7 +31,7 @@ class TestLiteJetLight(unittest.TestCase):
self.load_deactivated_callbacks = {}
def get_load_name(number):
return "Mock Load #" + str(number)
return f"Mock Load #{number}"
def on_load_activated(number, callback):
self.load_activated_callbacks[number] = callback

View File

@ -27,7 +27,7 @@ class TestLiteJetScene(unittest.TestCase):
self.hass.start()
def get_scene_name(number):
return "Mock Scene #" + str(number)
return f"Mock Scene #{number}"
self.mock_lj = mock_pylitejet.return_value
self.mock_lj.loads.return_value = range(0)

View File

@ -31,7 +31,7 @@ class TestLiteJetSwitch(unittest.TestCase):
self.switch_released_callbacks = {}
def get_switch_name(number):
return "Mock Switch #" + str(number)
return f"Mock Switch #{number}"
def on_switch_pressed(number, callback):
self.switch_pressed_callbacks[number] = callback

View File

@ -189,7 +189,7 @@ class TestAlarmControlPanelManualMqtt(unittest.TestCase):
assert STATE_ALARM_DISARMED == self.hass.states.get(entity_id).state
common.alarm_arm_home(self.hass, CODE + "2")
common.alarm_arm_home(self.hass, f"{CODE}2")
self.hass.block_till_done()
assert STATE_ALARM_DISARMED == self.hass.states.get(entity_id).state
@ -342,7 +342,7 @@ class TestAlarmControlPanelManualMqtt(unittest.TestCase):
assert STATE_ALARM_DISARMED == self.hass.states.get(entity_id).state
common.alarm_arm_away(self.hass, CODE + "2")
common.alarm_arm_away(self.hass, f"{CODE}2")
self.hass.block_till_done()
assert STATE_ALARM_DISARMED == self.hass.states.get(entity_id).state
@ -473,7 +473,7 @@ class TestAlarmControlPanelManualMqtt(unittest.TestCase):
assert STATE_ALARM_DISARMED == self.hass.states.get(entity_id).state
common.alarm_arm_night(self.hass, CODE + "2")
common.alarm_arm_night(self.hass, f"{CODE}2")
self.hass.block_till_done()
assert STATE_ALARM_DISARMED == self.hass.states.get(entity_id).state
@ -942,7 +942,7 @@ class TestAlarmControlPanelManualMqtt(unittest.TestCase):
"platform": "manual_mqtt",
"name": "test",
"pending_time": 5,
"code": CODE + "2",
"code": f"{CODE}2",
"disarm_after_trigger": False,
"command_topic": "alarm/command",
"state_topic": "alarm/state",

View File

@ -99,7 +99,7 @@ class TestPlant(unittest.TestCase):
self.hass, plant.DOMAIN, {plant.DOMAIN: {plant_name: GOOD_CONFIG}}
)
self.hass.block_till_done()
state = self.hass.states.get("plant." + plant_name)
state = self.hass.states.get(f"plant.{plant_name}")
assert 5 == state.attributes[plant.READING_MOISTURE]
def test_update_states(self):
@ -113,7 +113,7 @@ class TestPlant(unittest.TestCase):
)
self.hass.states.set(MOISTURE_ENTITY, 5, {ATTR_UNIT_OF_MEASUREMENT: "us/cm"})
self.hass.block_till_done()
state = self.hass.states.get("plant." + plant_name)
state = self.hass.states.get(f"plant.{plant_name}")
assert STATE_PROBLEM == state.state
assert 5 == state.attributes[plant.READING_MOISTURE]
@ -130,7 +130,7 @@ class TestPlant(unittest.TestCase):
MOISTURE_ENTITY, STATE_UNAVAILABLE, {ATTR_UNIT_OF_MEASUREMENT: "us/cm"}
)
self.hass.block_till_done()
state = self.hass.states.get("plant." + plant_name)
state = self.hass.states.get(f"plant.{plant_name}")
assert state.state == STATE_PROBLEM
assert state.attributes[plant.READING_MOISTURE] == STATE_UNAVAILABLE
@ -145,14 +145,14 @@ class TestPlant(unittest.TestCase):
)
self.hass.states.set(MOISTURE_ENTITY, 42, {ATTR_UNIT_OF_MEASUREMENT: "us/cm"})
self.hass.block_till_done()
state = self.hass.states.get("plant." + plant_name)
state = self.hass.states.get(f"plant.{plant_name}")
assert state.state == STATE_OK
assert state.attributes[plant.READING_MOISTURE] == 42
self.hass.states.set(
MOISTURE_ENTITY, STATE_UNAVAILABLE, {ATTR_UNIT_OF_MEASUREMENT: "us/cm"}
)
self.hass.block_till_done()
state = self.hass.states.get("plant." + plant_name)
state = self.hass.states.get(f"plant.{plant_name}")
assert state.state == STATE_PROBLEM
assert state.attributes[plant.READING_MOISTURE] == STATE_UNAVAILABLE
@ -184,7 +184,7 @@ class TestPlant(unittest.TestCase):
)
self.hass.block_till_done()
state = self.hass.states.get("plant." + plant_name)
state = self.hass.states.get(f"plant.{plant_name}")
assert STATE_UNKNOWN == state.state
max_brightness = state.attributes.get(plant.ATTR_MAX_BRIGHTNESS_HISTORY)
assert 30 == max_brightness
@ -197,17 +197,17 @@ class TestPlant(unittest.TestCase):
)
self.hass.states.set(BRIGHTNESS_ENTITY, 100, {ATTR_UNIT_OF_MEASUREMENT: "lux"})
self.hass.block_till_done()
state = self.hass.states.get("plant." + plant_name)
state = self.hass.states.get(f"plant.{plant_name}")
assert STATE_PROBLEM == state.state
self.hass.states.set(BRIGHTNESS_ENTITY, 600, {ATTR_UNIT_OF_MEASUREMENT: "lux"})
self.hass.block_till_done()
state = self.hass.states.get("plant." + plant_name)
state = self.hass.states.get(f"plant.{plant_name}")
assert STATE_OK == state.state
self.hass.states.set(BRIGHTNESS_ENTITY, 100, {ATTR_UNIT_OF_MEASUREMENT: "lux"})
self.hass.block_till_done()
state = self.hass.states.get("plant." + plant_name)
state = self.hass.states.get(f"plant.{plant_name}")
assert STATE_OK == state.state

View File

@ -48,14 +48,14 @@ class TestProximity(unittest.TestCase):
proximities = ["home", "work"]
for prox in proximities:
state = self.hass.states.get("proximity." + prox)
state = self.hass.states.get(f"proximity.{prox}")
assert state.state == "not set"
assert state.attributes.get("nearest") == "not set"
assert state.attributes.get("dir_of_travel") == "not set"
self.hass.states.set("proximity." + prox, "0")
self.hass.states.set(f"proximity.{prox}", "0")
self.hass.block_till_done()
state = self.hass.states.get("proximity." + prox)
state = self.hass.states.get(f"proximity.{prox}")
assert state.state == "0"
def test_proximities_setup(self):

View File

@ -181,7 +181,7 @@ async def test_race_condition(hass, monkeypatch):
assert updated_sensor
# test state of new sensor
new_sensor = hass.states.get(DOMAIN + ".test3")
new_sensor = hass.states.get(f"{DOMAIN}.test3")
assert new_sensor
assert new_sensor.state == "ok"
@ -191,6 +191,6 @@ async def test_race_condition(hass, monkeypatch):
assert tmp_entity not in hass.data[DATA_ENTITY_LOOKUP][EVENT_KEY_SENSOR]["test3"]
# test state of new sensor
new_sensor = hass.states.get(DOMAIN + ".test3")
new_sensor = hass.states.get(f"{DOMAIN}.test3")
assert new_sensor
assert new_sensor.state == "ko"

View File

@ -40,7 +40,7 @@ async def test_entity_state(hass, device_factory):
await setup_platform(hass, BINARY_SENSOR_DOMAIN, devices=[device])
state = hass.states.get("binary_sensor.motion_sensor_1_motion")
assert state.state == "off"
assert state.attributes[ATTR_FRIENDLY_NAME] == device.label + " " + Attribute.motion
assert state.attributes[ATTR_FRIENDLY_NAME] == f"{device.label} {Attribute.motion}"
async def test_entity_and_device_attributes(hass, device_factory):
@ -56,7 +56,7 @@ async def test_entity_and_device_attributes(hass, device_factory):
# Assert
entry = entity_registry.async_get("binary_sensor.motion_sensor_1_motion")
assert entry
assert entry.unique_id == device.device_id + "." + Attribute.motion
assert entry.unique_id == f"{device.device_id}.{Attribute.motion}"
entry = device_registry.async_get_device({(DOMAIN, device.device_id)}, [])
assert entry
assert entry.name == device.label

View File

@ -84,7 +84,7 @@ async def test_entity_and_device_attributes(hass, device_factory):
# Assert
entry = entity_registry.async_get("sensor.sensor_1_battery")
assert entry
assert entry.unique_id == f"{device.device_id}." + Attribute.battery
assert entry.unique_id == f"{device.device_id}.{Attribute.battery}"
entry = device_registry.async_get_device({(DOMAIN, device.device_id)}, [])
assert entry
assert entry.name == device.label

View File

@ -15,4 +15,4 @@ def pytest_runtest_makereport(item, call):
# set a report attribute for each phase of a call, which can
# be "setup", "call", "teardown"
setattr(item, "rep_" + rep.when, rep)
setattr(item, f"rep_{rep.when}", rep)

View File

@ -138,7 +138,7 @@ async def test_invalid_data(hass, aioclient_mock):
await async_setup_component(hass, "sensor", {"sensor": VALID_CONFIG})
for condition in VALID_CONFIG["monitored_conditions"]:
state = hass.states.get("sensor.pws_" + condition)
state = hass.states.get(f"sensor.pws_{condition}")
assert state.state == STATE_UNKNOWN

View File

@ -70,7 +70,7 @@ def mocked_requests(*args, **kwargs):
},
200,
)
if str(args[0]).endswith("timedOut/" + URL_LIST_END) and FIRST_CALL is True:
if str(args[0]).endswith(f"timedOut/{URL_LIST_END}") and FIRST_CALL is True:
FIRST_CALL = False
# deliver an error when called with expired token
return MockResponse({"code": "401", "msg": "Invalid token"}, 200)

View File

@ -245,7 +245,7 @@ class TestNotifyYesssSMS(unittest.TestCase):
# pylint: disable=protected-access
self.yessssms.yesss._kontomanager,
status_code=200,
text="test..." + login + "</a>",
text=f"test...{login}</a>",
)
mock.register_uri(
"POST",
@ -312,7 +312,7 @@ class TestNotifyYesssSMS(unittest.TestCase):
# pylint: disable=protected-access
self.yessssms.yesss._kontomanager,
status_code=200,
text="test..." + login + "</a>",
text=f"test...{login}</a>",
)
mock.register_uri(
"POST",

View File

@ -38,7 +38,7 @@ def teardown():
def _path_for(leaf_name):
return os.path.join(TMP_DIR, leaf_name + ".json")
return os.path.join(TMP_DIR, f"{leaf_name}.json")
def test_save_and_load():

View File

@ -129,7 +129,7 @@ def teardown():
def _path_for(leaf_name):
return os.path.join(TMP_DIR, leaf_name + ".yaml")
return os.path.join(TMP_DIR, f"{leaf_name}.yaml")
def test_save_and_load():