Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to Python 3.10 #649

Merged
merged 1 commit into from
Feb 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/home-assistant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
pull_request:

env:
DEFAULT_PYTHON: 3.9
DEFAULT_PYTHON: "3.10"

jobs:
hacs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linting.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: Pre-commit
strategy:
matrix:
python-version: [3.9]
python-version: ["3.10"]
runs-on: ubuntu-latest
steps:
- name: Check out the repository
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
name: Update manifest and publish
strategy:
matrix:
python-version: [3.9]
python-version: ["3.10"]
runs-on: ubuntu-latest
steps:
- name: Check out the repository
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
rev: v4.4.0
hooks:
- id: check-added-large-files
- id: check-json
Expand Down Expand Up @@ -43,20 +43,20 @@ repos:
pass_filenames: false
always_run: true
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.2.1
rev: v2.7.1
hooks:
- id: prettier
exclude: ^custom_components/google_home/manifest\.json$
- repo: https://github.com/cdce8p/python-typing-update
rev: v0.3.3
rev: v0.5.1
hooks:
# Run `python-typing-update` hook manually from time to time
# to update python typing syntax.
# Will require manual work, before submitting changes!
- id: python-typing-update
stages: [manual]
args:
- --py38-plus
- --py310-plus
- --force
- --keep-updates
files: ^.+\.py$
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ data:

### Prerequisites

Use Home Assistant v2022.6.0 or above.
Use Home Assistant v2023.2.0 or above.

### Google Account security

Expand Down
6 changes: 3 additions & 3 deletions custom_components/google_home/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import asyncio
from http import HTTPStatus
import logging
from typing import List, Literal, cast
from typing import Literal, cast

from aiohttp import ClientError, ClientSession
from aiohttp.client_exceptions import ClientConnectorError, ContentTypeError
Expand Down Expand Up @@ -164,8 +164,8 @@ async def update_alarms_and_timers(

if response is not None:
if JSON_TIMER in response and JSON_ALARM in response:
device.set_timers(cast(List[TimerJsonDict], response[JSON_TIMER]))
device.set_alarms(cast(List[AlarmJsonDict], response[JSON_ALARM]))
device.set_timers(cast(list[TimerJsonDict], response[JSON_TIMER]))
device.set_alarms(cast(list[AlarmJsonDict], response[JSON_ALARM]))
_LOGGER.debug(
"Successfully retrieved alarms and timers from %s. Response: %s",
device.name,
Expand Down
2 changes: 1 addition & 1 deletion custom_components/google_home/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from .types import DeviceInfo


class GoogleHomeBaseEntity(CoordinatorEntity, ABC):
class GoogleHomeBaseEntity(CoordinatorEntity[DataUpdateCoordinator], ABC):
"""Base entity base for Google Home sensors"""

def __init__(
Expand Down
5 changes: 3 additions & 2 deletions custom_components/google_home/types.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""Various types used in type hints."""
from __future__ import annotations

from typing import List, Mapping, TypedDict, Union
from collections.abc import Mapping
from typing import TypedDict, Union


class AlarmJsonDict(TypedDict, total=False):
Expand Down Expand Up @@ -97,5 +98,5 @@ class OptionsFlowDict(TypedDict):

JsonDict = Mapping[
str,
Union[bool, float, int, str, List[str], List[AlarmJsonDict], List[TimerJsonDict]],
Union[bool, float, int, str, list[str], list[AlarmJsonDict], list[TimerJsonDict]],
]
2 changes: 1 addition & 1 deletion hacs.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "Google Home",
"homeassistant": "2022.6.0",
"homeassistant": "2023.2.0",
"render_readme": true
}
663 changes: 297 additions & 366 deletions poetry.lock

Large diffs are not rendered by default.

34 changes: 24 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,26 @@ license = "MIT"
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.9"
python = "^3.10"
glocaltokens = "^0.6.8"
homeassistant = "2022.12.9"
homeassistant = "^2023.2.0"

[tool.poetry.group.dev.dependencies]
black = "^22.12"
black = "^23.1.0"
codespell = "^2.2.2"
flake8 = "^5.0.4"
flake8-bugbear = "^22.12.6"
flake8 = "^6.0.0"
flake8-bugbear = "^23.1.20"
flake8-comprehensions = "^3.10.1"
flake8-simplify = "^0.19.3"
flake8-use-fstring = "^1.4"
homeassistant-stubs = "^2022.6.0"
homeassistant-stubs = "^2023.2.0"
isort = "^5.12.0"
mypy = "^0.971"
pre-commit = "^2.21.0"
mypy = "^0.991"
pre-commit = "^3.0.4"
PyGithub = "^1.57"
pylint = "^2.16.1"
types-requests = "^2.28.11"
setuptools = "^65.7.0"

voluptuous-stubs = "^0.1.1"

[tool.pylint.messages_control]
# Reasons disabled:
Expand All @@ -36,6 +35,7 @@ setuptools = "^65.7.0"
disable = [
"duplicate-code",
"too-few-public-methods",
"too-many-ancestors",
"too-many-arguments",
"too-many-instance-attributes",
"too-many-locals",
Expand All @@ -52,6 +52,20 @@ known_first_party = [
"homeassistant",
]

[tool.mypy]
python_version = "3.10"
show_error_codes = true
strict = true
disallow_any_explicit = true
disallow_any_unimported = true
warn_no_return = true
warn_unreachable = true

[tool.codespell]
quiet-level = 2
skip = "poetry.lock,./.git/*,./.mypy_cache/*,*.json"
ignore-words-list = "hass"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
18 changes: 0 additions & 18 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,3 @@ ignore =
E203,
D202,
W504

[mypy]
python_version = 3.9
show_error_codes = True
strict = True
disallow_any_explicit = True
disallow_any_unimported = True
show_none_errors = True
warn_no_return = True
warn_unreachable = True

[mypy-voluptuous.*]
ignore_missing_imports = True

[codespell]
quiet-level = 2
skip = poetry.lock,./.git,./.mypy_cache,*.json
ignore-words-list = hass