Skip to content

Commit

Permalink
Merge pull request #63 from iprak/handle-annotations
Browse files Browse the repository at this point in the history
Handle compatibility with python 3.8
  • Loading branch information
iprak authored Dec 18, 2021
2 parents 8aaec00 + a36abd3 commit dce8539
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions custom_components/yahoofinance/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
https://github.com/iprak/yahoofinance
"""

from __future__ import annotations

from datetime import timedelta
import logging
from typing import Final, Union
Expand Down
2 changes: 2 additions & 0 deletions custom_components/yahoofinance/const.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Constants for Yahoo Finance sensor."""

from __future__ import annotations

from typing import Final

# Additional attributes exposed by the sensor
Expand Down
1 change: 1 addition & 0 deletions custom_components/yahoofinance/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
https://github.com/iprak/yahoofinance
"""
from __future__ import annotations

from datetime import timedelta
import logging
Expand Down
2 changes: 2 additions & 0 deletions custom_components/yahoofinance/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
https://github.com/iprak/yahoofinance
"""

from __future__ import annotations

import logging
from timeit import default_timer as timer
from typing import Union
Expand Down
6 changes: 4 additions & 2 deletions tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,14 @@ async def test_setup_optionally_requests_coordinator_refresh(
async def test_refresh_symbols_service(hass, enable_custom_integrations):
"""Test refresh_symbols service callback."""

# Mock the refresh callback `_async_update` for testing
with patch(
f"{YSUC}.async_request_refresh", AsyncMock(return_value=None)
f"{YSUC}._async_update", AsyncMock(return_value=None)
) as mock_async_request_refresh:

assert await async_setup_component(hass, DOMAIN, SAMPLE_CONFIG) is True
await hass.async_block_till_done()
assert mock_async_request_refresh.call_count == 1

await hass.services.async_call(
DOMAIN,
Expand All @@ -183,7 +185,7 @@ async def test_refresh_symbols_service(hass, enable_custom_integrations):
)
await hass.async_block_till_done()

assert mock_async_request_refresh.call_count == 1
assert mock_async_request_refresh.call_count == 2


def test_SymbolDefinition_comparison():
Expand Down

0 comments on commit dce8539

Please sign in to comment.