Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4347476

Browse files
scopballoobfrenck
authoredJan 4, 2021
Drop remaining Python < 3.8 support (home-assistant#44743)
Co-authored-by: Paulus Schoutsen <[email protected]> Co-authored-by: Franck Nijhof <[email protected]>
1 parent 134db3f commit 4347476

17 files changed

+20
-72
lines changed
 

‎.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ repos:
33
rev: v2.7.2
44
hooks:
55
- id: pyupgrade
6-
args: [--py37-plus]
6+
args: [--py38-plus]
77
- repo: https://github.com/psf/black
88
rev: 20.8b1
99
hooks:

‎.readthedocs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build:
44
image: latest
55

66
python:
7-
version: 3.7
7+
version: 3.8
88
setup_py_install: true
99

1010
requirements_file: requirements_docs.txt

‎azure-pipelines-release.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ stages:
6060
vmImage: 'ubuntu-latest'
6161
steps:
6262
- task: UsePythonVersion@0
63-
displayName: 'Use Python 3.7'
63+
displayName: 'Use Python 3.8'
6464
inputs:
65-
versionSpec: '3.7'
65+
versionSpec: '3.8'
6666
- script: pip install twine wheel
6767
displayName: 'Install tools'
6868
- script: python setup.py sdist bdist_wheel

‎azure-pipelines-translation.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ jobs:
3030
vmImage: 'ubuntu-latest'
3131
steps:
3232
- task: UsePythonVersion@0
33-
displayName: 'Use Python 3.7'
33+
displayName: 'Use Python 3.8'
3434
inputs:
35-
versionSpec: '3.7'
35+
versionSpec: '3.8'
3636
- script: |
3737
export LOKALISE_TOKEN="$(lokaliseToken)"
3838
export AZURE_BRANCH="$(Build.SourceBranchName)"

‎homeassistant/bootstrap.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -307,12 +307,10 @@ def async_enable_logging(
307307
sys.excepthook = lambda *args: logging.getLogger(None).exception(
308308
"Uncaught exception", exc_info=args # type: ignore
309309
)
310-
311-
if sys.version_info[:2] >= (3, 8):
312-
threading.excepthook = lambda args: logging.getLogger(None).exception(
313-
"Uncaught thread exception",
314-
exc_info=(args.exc_type, args.exc_value, args.exc_traceback),
315-
)
310+
threading.excepthook = lambda args: logging.getLogger(None).exception(
311+
"Uncaught thread exception",
312+
exc_info=(args.exc_type, args.exc_value, args.exc_traceback), # type: ignore[arg-type]
313+
)
316314

317315
# Log errors to a file if we have write access to file or config dir
318316
if log_file is None:

‎homeassistant/core.py

-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@
7373
from homeassistant.util import location, network
7474
from homeassistant.util.async_ import fire_coroutine_threadsafe, run_callback_threadsafe
7575
import homeassistant.util.dt as dt_util
76-
from homeassistant.util.thread import fix_threading_exception_logging
7776
from homeassistant.util.timeout import TimeoutManager
7877
from homeassistant.util.unit_system import IMPERIAL_SYSTEM, METRIC_SYSTEM, UnitSystem
7978
import homeassistant.util.uuid as uuid_util
@@ -86,7 +85,6 @@
8685

8786

8887
block_async_io.enable()
89-
fix_threading_exception_logging()
9088

9189
T = TypeVar("T")
9290
_UNDEF: dict = {} # Internal; not helpers.typing.UNDEFINED due to circular dependency

‎homeassistant/package_constraints.txt

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ emoji==0.5.4
1515
hass-nabucasa==0.39.0
1616
home-assistant-frontend==20201229.0
1717
httpx==0.16.1
18-
importlib-metadata==1.6.0;python_version<'3.8'
1918
jinja2>=2.11.2
2019
netdisco==2.8.2
2120
paho-mqtt==1.5.1

‎homeassistant/runner.py

+1-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from concurrent.futures import ThreadPoolExecutor
44
import dataclasses
55
import logging
6-
import sys
76
from typing import Any, Dict, Optional
87

98
from homeassistant import bootstrap
@@ -41,14 +40,7 @@ class RuntimeConfig:
4140
open_ui: bool = False
4241

4342

44-
# In Python 3.8+ proactor policy is the default on Windows
45-
if sys.platform == "win32" and sys.version_info[:2] < (3, 8):
46-
PolicyBase = asyncio.WindowsProactorEventLoopPolicy
47-
else:
48-
PolicyBase = asyncio.DefaultEventLoopPolicy
49-
50-
51-
class HassEventLoopPolicy(PolicyBase): # type: ignore
43+
class HassEventLoopPolicy(asyncio.DefaultEventLoopPolicy): # type: ignore[valid-type,misc]
5244
"""Event loop policy for Home Assistant."""
5345

5446
def __init__(self, debug: bool) -> None:

‎homeassistant/util/package.py

+1-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Helpers to install PyPi packages."""
22
import asyncio
3+
from importlib.metadata import PackageNotFoundError, version
34
import logging
45
import os
56
from pathlib import Path
@@ -10,17 +11,6 @@
1011

1112
import pkg_resources
1213

13-
if sys.version_info[:2] >= (3, 8):
14-
from importlib.metadata import ( # pylint: disable=no-name-in-module,import-error
15-
PackageNotFoundError,
16-
version,
17-
)
18-
else:
19-
from importlib_metadata import ( # pylint: disable=import-error
20-
PackageNotFoundError,
21-
version,
22-
)
23-
2414
_LOGGER = logging.getLogger(__name__)
2515

2616

‎homeassistant/util/thread.py

-23
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,10 @@
11
"""Threading util helpers."""
22
import ctypes
33
import inspect
4-
import sys
54
import threading
65
from typing import Any
76

87

9-
def fix_threading_exception_logging() -> None:
10-
"""Fix threads passing uncaught exceptions to our exception hook.
11-
12-
https://bugs.python.org/issue1230540
13-
Fixed in Python 3.8.
14-
"""
15-
if sys.version_info[:2] >= (3, 8):
16-
return
17-
18-
run_old = threading.Thread.run
19-
20-
def run(*args: Any, **kwargs: Any) -> None:
21-
try:
22-
run_old(*args, **kwargs)
23-
except (KeyboardInterrupt, SystemExit): # pylint: disable=try-except-raise
24-
raise
25-
except Exception: # pylint: disable=broad-except
26-
sys.excepthook(*sys.exc_info())
27-
28-
threading.Thread.run = run # type: ignore
29-
30-
318
def _async_raise(tid: int, exctype: Any) -> None:
329
"""Raise an exception in the threads with id tid."""
3310
if not inspect.isclass(exctype):

‎pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tool.black]
2-
target-version = ["py37", "py38"]
2+
target-version = ["py38"]
33
exclude = 'generated'
44

55
[tool.isort]

‎requirements.txt

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ bcrypt==3.1.7
99
certifi>=2020.12.5
1010
ciso8601==2.1.3
1111
httpx==0.16.1
12-
importlib-metadata==1.6.0;python_version<'3.8'
1312
jinja2>=2.11.2
1413
PyJWT==1.7.1
1514
cryptography==3.2

‎setup.cfg

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ classifier =
1111
Intended Audience :: Developers
1212
License :: OSI Approved :: Apache Software License
1313
Operating System :: OS Independent
14-
Programming Language :: Python :: 3.7
14+
Programming Language :: Python :: 3.8
15+
Programming Language :: Python :: 3.9
1516
Topic :: Home Automation
1617

1718
[flake8]
@@ -31,7 +32,7 @@ ignore =
3132
W504
3233

3334
[mypy]
34-
python_version = 3.7
35+
python_version = 3.8
3536
show_error_codes = true
3637
ignore_errors = true
3738
follow_imports = silent

‎setup.py

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
"certifi>=2020.12.5",
4141
"ciso8601==2.1.3",
4242
"httpx==0.16.1",
43-
"importlib-metadata==1.6.0;python_version<'3.8'",
4443
"jinja2>=2.11.2",
4544
"PyJWT==1.7.1",
4645
# PyJWT has loose dependency. We want the latest one.

‎tests/components/plex/mock_classes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def playlist(self, playlist):
247247
"""Mock the playlist lookup method."""
248248
return MockPlexMediaItem(playlist, mediatype="playlist")
249249

250-
@lru_cache()
250+
@lru_cache
251251
def playlists(self):
252252
"""Mock the playlists lookup method with a lazy init."""
253253
return [

‎tests/components/webostv/test_media_player.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""The tests for the LG webOS media player platform."""
2-
import sys
2+
3+
from unittest.mock import patch
34

45
import pytest
56

@@ -25,12 +26,6 @@
2526
)
2627
from homeassistant.setup import async_setup_component
2728

28-
if sys.version_info >= (3, 8, 0):
29-
from unittest.mock import patch
30-
else:
31-
from unittest.mock import patch
32-
33-
3429
NAME = "fake"
3530
ENTITY_ID = f"{media_player.DOMAIN}.{NAME}"
3631

‎tox.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py37, py38, lint, pylint, typing, cov
2+
envlist = py38, py39, lint, pylint, typing, cov
33
skip_missing_interpreters = True
44
ignore_basepython_conflict = True
55

0 commit comments

Comments
 (0)
Please sign in to comment.