Skip to content

Commit 445fd15

Browse files
scopballoob
authored andcommitted
Drop Python 3.6 support (home-assistant#29978)
1 parent bfafa77 commit 445fd15

15 files changed

+19
-135
lines changed

.coveragerc

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ omit =
55
homeassistant/__main__.py
66
homeassistant/helpers/signal.py
77
homeassistant/helpers/typing.py
8-
homeassistant/monkey_patch.py
98
homeassistant/scripts/*.py
109
homeassistant/util/async.py
1110

.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.6
7+
version: 3.7
88
setup_py_install: true
99

1010
requirements_file: requirements_docs.txt

.travis.yml

+4-6
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@ addons:
1414
matrix:
1515
fast_finish: true
1616
include:
17-
- python: "3.6.1"
17+
- python: "3.7.0"
1818
env: TOXENV=lint
19-
- python: "3.6.1"
19+
- python: "3.7.0"
2020
env: TOXENV=pylint PYLINT_ARGS=--jobs=0 TRAVIS_WAIT=30
21-
- python: "3.6.1"
21+
- python: "3.7.0"
2222
env: TOXENV=typing
23-
- python: "3.6.1"
24-
env: TOXENV=py36
25-
- python: "3.7"
23+
- python: "3.7.0"
2624
env: TOXENV=py37
2725

2826
cache:

azure-pipelines-ci.yml

+1-5
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ pr:
1414

1515
resources:
1616
containers:
17-
- container: 36
18-
image: homeassistant/ci-azure:3.6
1917
- container: 37
2018
image: homeassistant/ci-azure:3.7
2119
repositories:
@@ -25,7 +23,7 @@ resources:
2523
endpoint: 'home-assistant'
2624
variables:
2725
- name: PythonMain
28-
value: '36'
26+
value: '37'
2927
- group: codecov
3028

3129
stages:
@@ -108,8 +106,6 @@ stages:
108106
strategy:
109107
maxParallel: 3
110108
matrix:
111-
Python36:
112-
python.container: '36'
113109
Python37:
114110
python.container: '37'
115111
container: $[ variables['python.container'] ]

homeassistant/__main__.py

+3-11
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
"""Start Home Assistant."""
22
import argparse
3+
import asyncio
34
import os
45
import platform
56
import subprocess
67
import sys
78
import threading
89
from typing import TYPE_CHECKING, Any, Dict, List
910

10-
from homeassistant import monkey_patch
1111
from homeassistant.const import REQUIRED_PYTHON_VER, RESTART_EXIT_CODE, __version__
1212

1313
if TYPE_CHECKING:
@@ -16,7 +16,6 @@
1616

1717
def set_loop() -> None:
1818
"""Attempt to use different loop."""
19-
import asyncio
2019
from asyncio.events import BaseDefaultEventLoopPolicy
2120

2221
if sys.platform == "win32":
@@ -345,11 +344,6 @@ def main() -> int:
345344
"""Start Home Assistant."""
346345
validate_python()
347346

348-
monkey_patch_needed = sys.version_info[:3] < (3, 6, 3)
349-
if monkey_patch_needed and os.environ.get("HASS_NO_MONKEY") != "1":
350-
monkey_patch.disable_c_asyncio()
351-
monkey_patch.patch_weakref_tasks()
352-
353347
set_loop()
354348

355349
# Run a simple daemon runner process on Windows to handle restarts
@@ -383,13 +377,11 @@ def main() -> int:
383377
if args.pid_file:
384378
write_pid(args.pid_file)
385379

386-
from homeassistant.util.async_ import asyncio_run
387-
388-
exit_code = asyncio_run(setup_and_run_hass(config_dir, args))
380+
exit_code = asyncio.run(setup_and_run_hass(config_dir, args))
389381
if exit_code == RESTART_EXIT_CODE and not args.runner:
390382
try_to_restart()
391383

392-
return exit_code # type: ignore
384+
return exit_code
393385

394386

395387
if __name__ == "__main__":

homeassistant/const.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
PATCH_VERSION = "0.dev0"
55
__short_version__ = "{}.{}".format(MAJOR_VERSION, MINOR_VERSION)
66
__version__ = "{}.{}".format(__short_version__, PATCH_VERSION)
7-
REQUIRED_PYTHON_VER = (3, 6, 1)
7+
REQUIRED_PYTHON_VER = (3, 7, 0)
88
# Truthy date string triggers showing related deprecation warning messages.
9-
REQUIRED_NEXT_PYTHON_VER = (3, 7, 0)
10-
REQUIRED_NEXT_PYTHON_DATE = "December 15, 2019"
9+
REQUIRED_NEXT_PYTHON_VER = (3, 8, 0)
10+
REQUIRED_NEXT_PYTHON_DATE = ""
1111

1212
# Format for platform files
1313
PLATFORM_FORMAT = "{platform}.{domain}"

homeassistant/monkey_patch.py

-73
This file was deleted.

homeassistant/package_constraints.txt

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ async_timeout==3.0.1
77
attrs==19.3.0
88
bcrypt==3.1.7
99
certifi>=2019.11.28
10-
contextvars==2.4;python_version<"3.7"
1110
cryptography==2.8
1211
defusedxml==0.6.0
1312
distro==1.4.0
@@ -29,7 +28,7 @@ zeroconf==0.24.0
2928

3029
pycryptodome>=3.6.6
3130

32-
# Breaks Python 3.6 and is not needed for our supported Python versions
31+
# Not needed for our supported Python versions
3332
enum34==1000000000.0.0
3433

3534
# This is a old unmaintained library and is replaced with pycryptodome

homeassistant/util/async_.py

+1-20
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,14 @@
11
"""Asyncio backports for Python 3.6 compatibility."""
2-
import asyncio
32
from asyncio import coroutines, ensure_future
43
from asyncio.events import AbstractEventLoop
54
import concurrent.futures
65
import logging
76
import threading
8-
from typing import Any, Awaitable, Callable, Coroutine, TypeVar
7+
from typing import Any, Callable, Coroutine
98

109
_LOGGER = logging.getLogger(__name__)
1110

1211

13-
try:
14-
# pylint: disable=invalid-name
15-
asyncio_run = asyncio.run # type: ignore
16-
except AttributeError:
17-
_T = TypeVar("_T")
18-
19-
def asyncio_run(main: Awaitable[_T], *, debug: bool = False) -> _T:
20-
"""Minimal re-implementation of asyncio.run (since 3.7)."""
21-
loop = asyncio.new_event_loop()
22-
asyncio.set_event_loop(loop)
23-
loop.set_debug(debug)
24-
try:
25-
return loop.run_until_complete(main)
26-
finally:
27-
asyncio.set_event_loop(None)
28-
loop.close()
29-
30-
3112
def fire_coroutine_threadsafe(coro: Coroutine, loop: AbstractEventLoop) -> None:
3213
"""Submit a coroutine object to a given event loop.
3314

pyproject.toml

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

requirements_all.txt

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ async_timeout==3.0.1
55
attrs==19.3.0
66
bcrypt==3.1.7
77
certifi>=2019.11.28
8-
contextvars==2.4;python_version<"3.7"
98
importlib-metadata==0.23
109
jinja2>=2.10.3
1110
PyJWT==1.7.1

script/gen_requirements_all.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
CONSTRAINT_BASE = """
5959
pycryptodome>=3.6.6
6060
61-
# Breaks Python 3.6 and is not needed for our supported Python versions
61+
# Not needed for our supported Python versions
6262
enum34==1000000000.0.0
6363
6464
# This is a old unmaintained library and is replaced with pycryptodome

setup.cfg

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ classifier =
1111
Intended Audience :: Developers
1212
License :: OSI Approved :: Apache Software License
1313
Operating System :: OS Independent
14-
Programming Language :: Python :: 3.6
1514
Programming Language :: Python :: 3.7
1615
Topic :: Home Automation
1716

@@ -57,15 +56,15 @@ forced_separate = tests
5756
combine_as_imports = true
5857

5958
[mypy]
60-
python_version = 3.6
59+
python_version = 3.7
6160
ignore_errors = true
6261
follow_imports = silent
6362
ignore_missing_imports = true
6463
warn_incomplete_stub = true
6564
warn_redundant_casts = true
6665
warn_unused_configs = true
6766

68-
[mypy-homeassistant.bootstrap,homeassistant.components,homeassistant.config_entries,homeassistant.config,homeassistant.const,homeassistant.core,homeassistant.data_entry_flow,homeassistant.exceptions,homeassistant.loader,homeassistant.__main__,homeassistant.monkey_patch,homeassistant.requirements,homeassistant.setup,homeassistant.util,homeassistant.auth.*,homeassistant.components.automation.*,homeassistant.components.binary_sensor.*,homeassistant.components.calendar.*,homeassistant.components.cover.*,homeassistant.components.device_automation.*,homeassistant.components.frontend.*,homeassistant.components.geo_location.*,homeassistant.components.group.*,homeassistant.components.history.*,homeassistant.components.http.*,homeassistant.components.image_processing.*,homeassistant.components.integration.*,homeassistant.components.light.*,homeassistant.components.lock.*,homeassistant.components.mailbox.*,homeassistant.components.media_player.*,homeassistant.components.notify.*,homeassistant.components.persistent_notification.*,homeassistant.components.proximity.*,homeassistant.components.remote.*,homeassistant.components.scene.*,homeassistant.components.sensor.*,homeassistant.components.sun.*,homeassistant.components.switch.*,homeassistant.components.systemmonitor.*,homeassistant.components.tts.*,homeassistant.components.vacuum.*,homeassistant.components.water_heater.*,homeassistant.components.weather.*,homeassistant.components.websocket_api.*,homeassistant.components.zone.*,homeassistant.helpers.*,homeassistant.scripts.*,homeassistant.util.*]
67+
[mypy-homeassistant.bootstrap,homeassistant.components,homeassistant.config_entries,homeassistant.config,homeassistant.const,homeassistant.core,homeassistant.data_entry_flow,homeassistant.exceptions,homeassistant.loader,homeassistant.__main__,homeassistant.requirements,homeassistant.setup,homeassistant.util,homeassistant.auth.*,homeassistant.components.automation.*,homeassistant.components.binary_sensor.*,homeassistant.components.calendar.*,homeassistant.components.cover.*,homeassistant.components.device_automation.*,homeassistant.components.frontend.*,homeassistant.components.geo_location.*,homeassistant.components.group.*,homeassistant.components.history.*,homeassistant.components.http.*,homeassistant.components.image_processing.*,homeassistant.components.integration.*,homeassistant.components.light.*,homeassistant.components.lock.*,homeassistant.components.mailbox.*,homeassistant.components.media_player.*,homeassistant.components.notify.*,homeassistant.components.persistent_notification.*,homeassistant.components.proximity.*,homeassistant.components.remote.*,homeassistant.components.scene.*,homeassistant.components.sensor.*,homeassistant.components.sun.*,homeassistant.components.switch.*,homeassistant.components.systemmonitor.*,homeassistant.components.tts.*,homeassistant.components.vacuum.*,homeassistant.components.water_heater.*,homeassistant.components.weather.*,homeassistant.components.websocket_api.*,homeassistant.components.zone.*,homeassistant.helpers.*,homeassistant.scripts.*,homeassistant.util.*]
6968
ignore_errors = false
7069
check_untyped_defs = true
7170
disallow_incomplete_defs = true

setup.py

-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
"attrs==19.3.0",
3939
"bcrypt==3.1.7",
4040
"certifi>=2019.11.28",
41-
'contextvars==2.4;python_version<"3.7"',
4241
"importlib-metadata==0.23",
4342
"jinja2>=2.10.3",
4443
"PyJWT==1.7.1",

tests/util/test_async.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Tests for async util methods from Python source."""
22
import asyncio
3-
import sys
43
from unittest import TestCase
54
from unittest.mock import MagicMock, patch
65

@@ -112,11 +111,7 @@ def add_coroutine(self, a, b, fail, invalid, cancel):
112111
"""Wait 0.05 second and return a + b."""
113112
yield from asyncio.sleep(0.05, loop=self.loop)
114113
if cancel:
115-
if sys.version_info[:2] >= (3, 7):
116-
current_task = asyncio.current_task
117-
else:
118-
current_task = asyncio.tasks.Task.current_task
119-
current_task(self.loop).cancel()
114+
asyncio.current_task(self.loop).cancel()
120115
yield
121116
return self.add_callback(a, b, fail, invalid)
122117

0 commit comments

Comments
 (0)