Skip to content

Commit

Permalink
style: update Ruff format rules and related code style changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ttu committed Jan 12, 2025
1 parent 19c1a29 commit 3e859b5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/post_to_mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from ruuvitag_sensor.ruuvitag import RuuviTag

parser = argparse.ArgumentParser(
description="Program relays Ruuvitag BLE temperature and humidity" "advertisements to MQTT broker."
description="Program relays Ruuvitag BLE temperature and humidity advertisements to MQTT broker."
)
parser.add_argument("-m", "--mac", dest="mac_address", required=True, help="Ruuvitag MAC address")
parser.add_argument("-b", "--broker", dest="mqtt_broker", required=True, help="mqtt broker address, ip or fqdn")
Expand Down
4 changes: 2 additions & 2 deletions examples/reactive_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
# when temperature goes over 80 degrees
ruuvi_rx.get_subject().pipe(
ops.filter(lambda x: x[0] == "F4:A5:74:89:16:57"), ops.filter(lambda x: x[1]["temperature"] > 80), ops.take(1)
).subscribe(lambda x: print(f'Sauna is ready! Temperature: {x[1]["temperature"]}'))
).subscribe(lambda x: print(f"Sauna is ready! Temperature: {x[1]['temperature']}"))

# Execute only every time when pressure changes for F4:A5:74:89:16:57
ruuvi_rx.get_subject().pipe(
ops.filter(lambda x: x[0] == "F4:A5:74:89:16:57"), ops.distinct_until_changed(lambda x: x[1]["pressure"])
).subscribe(lambda x: print(f'Pressure changed: {x[1]["pressure"]}'))
).subscribe(lambda x: print(f"Pressure changed: {x[1]['pressure']}"))
2 changes: 1 addition & 1 deletion examples/send_updated_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async def send_post(session, update_data):

async def send_put(session, update_data):
async with session.put(
f'{server_url}/sensors/{quote(update_data["mac"])}',
f"{server_url}/sensors/{quote(update_data['mac'])}",
data=json.dumps(update_data),
headers={"content-type": "application/json"},
) as response:
Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ ignore = [
"RUF006", # Store a reference to the return value of asyncio.create_task
]

[tool.ruff.format]
quote-style = "double"
indent-style = "space"
skip-magic-trailing-comma = false

[tool.ruff.lint.mccabe]
max-complexity = 12

Expand Down

0 comments on commit 3e859b5

Please sign in to comment.