Skip to content

Commit

Permalink
Switch to ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
natekspencer committed Mar 4, 2024
1 parent 87cdc9c commit 4295019
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 266 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,8 @@ jobs:
run: poetry install
- name: Run linting
run: |
poetry run isort .
poetry run black . --check --extend-exclude proto
poetry run flake8 .
poetry run pylint vivintpy tests
poetry run pydocstyle vivintpy tests
poetry run ruff check
poetry run ruff format --check
- name: Run mypy
run: poetry run mypy vivintpy tests
- name: Test with pytest
Expand Down
266 changes: 27 additions & 239 deletions poetry.lock

Large diffs are not rendered by default.

6 changes: 1 addition & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,9 @@ pytest = "^7.2.2"
pytest-asyncio = "^0.21.0"
pytest-cov = "^4.0.0"
pytest-timeout = "^2.1.0"
black = "^23.3.0"
flake8 = ">=5.0.4,<7.0.0"
isort = "^5.11.5"
mypy = "^1.4"
pydocstyle = "^6.3.0"
pylint = ">=2.17.4,<4.0.0"
grpcio-tools = "1.60.1"
ruff = "^0.2.0"

[tool.poetry-dynamic-versioning]
enable = true
Expand Down
1 change: 1 addition & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extend-exclude = ["proto"]
7 changes: 2 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ commands =
[testenv:lint]
ignore_errors = True
commands =
poetry run isort .
poetry run black . --check --extend-exclude proto
poetry run flake8 .
poetry run pylint vivintpy tests
poetry run pydocstyle vivintpy tests
poetry run ruff check
poetry run ruff format --check

[testenv:mypy]
ignore_errors = True
Expand Down
5 changes: 2 additions & 3 deletions vivintpy/devices/alarm_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,8 @@ def handle_pubnub_message(self, message: dict) -> None:
# for the sake of consistency, we also need to update the panel's raw data
raw_device_data = first_or_none(
self.data[Attribute.DEVICES],
lambda raw_device_data, device_data=device_data: raw_device_data[ # type: ignore
"_id"
]
lambda raw_device_data, # type: ignore
device_data=device_data: raw_device_data["_id"]
== device_data["_id"],
)

Expand Down
7 changes: 5 additions & 2 deletions vivintpy/devices/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,18 @@ async def get_thumbnail_url(self) -> str | None:
)

async def get_rtsp_url(
self, internal: bool = False, hd: bool = False # pylint: disable=invalid-name
self,
internal: bool = False,
hd: bool = False, # pylint: disable=invalid-name
) -> str:
"""Return the rtsp URL for the camera."""
credentials = await self.alarm_panel.get_panel_credentials()
url = self.data[f"c{'i' if internal else 'e'}u{'' if hd else 's'}"][0]
return f"{url[:7]}{credentials[PanelCredentialAttribute.NAME]}:{credentials[PanelCredentialAttribute.PASSWORD]}@{url[7:]}"

async def get_direct_rtsp_url(
self, hd: bool = False # pylint: disable=invalid-name
self,
hd: bool = False, # pylint: disable=invalid-name
) -> str | None:
"""Return the direct rtsp url for this camera, in HD if requested, if any."""
return (
Expand Down
16 changes: 9 additions & 7 deletions vivintpy/vivintskyapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,15 @@ async def set_camera_as_doorbell_chime_extender(

async with grpc.aio.secure_channel(GRPC_ENDPOINT, credentials=creds) as channel:
stub: beam_pb2_grpc.BeamStub = beam_pb2_grpc.BeamStub(channel) # type: ignore
response: beam_pb2.SetUseAsDoorbellChimeExtenderResponse = await stub.SetUseAsDoorbellChimeExtender(
beam_pb2.SetUseAsDoorbellChimeExtenderRequest( # pylint: disable=no-member
panel_id=panel_id,
device_id=device_id,
use_as_doorbell_chime_extender=state,
),
metadata=[("session", cookie.value)],
response: beam_pb2.SetUseAsDoorbellChimeExtenderResponse = (
await stub.SetUseAsDoorbellChimeExtender(
beam_pb2.SetUseAsDoorbellChimeExtenderRequest( # pylint: disable=no-member
panel_id=panel_id,
device_id=device_id,
use_as_doorbell_chime_extender=state,
),
metadata=[("session", cookie.value)],
)
)

_LOGGER.debug("Response received: %s", str(response))
Expand Down

0 comments on commit 4295019

Please sign in to comment.