diff --git a/pylintrc b/pylintrc deleted file mode 100644 index c4f4c16b9..000000000 --- a/pylintrc +++ /dev/null @@ -1,45 +0,0 @@ -[MASTER] -reports=no -jobs=2 - -good-names=id,i,j,k,ex,Run,_,fp,T,os - -extension-pkg-whitelist= - ciso8601 - -# Reasons disabled: -# format - handled by black -# locally-disabled - it spams too much -# duplicate-code - unavoidable -# cyclic-import - doesn't test if both import on load -# abstract-class-not-used - is flaky, should not show up but does -# unused-argument - generic callbacks and setup methods create a lot of warnings -# too-many-* - are not enforced for the sake of readability -# too-few-* - same as too-many-* -# abstract-method - with intro of async there are always methods missing -disable= - format, - abstract-method, - cyclic-import, - duplicate-code, - locally-disabled, - no-else-return, - not-context-manager, - too-few-public-methods, - too-many-arguments, - too-many-branches, - too-many-instance-attributes, - too-many-lines, - too-many-locals, - too-many-public-methods, - too-many-return-statements, - too-many-statements, - unused-argument, - consider-using-with - -[EXCEPTIONS] -overgeneral-exceptions=builtins.Exception - - -[TYPECHECK] -ignored-modules = distutils diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..67b7c34c8 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,112 @@ +[build-system] +requires = ["setuptools~=68.0.0", "wheel~=0.40.0"] +build-backend = "setuptools.build_meta" + +[project] +name = "Supervisor" +dynamic = ["version", "dependencies"] +license = { text = "Apache-2.0" } +description = "Open-source private cloud os for Home-Assistant based on HassOS" +readme = "README.md" +authors = [ + { name = "The Home Assistant Authors", email = "hello@home-assistant.io" }, +] +keywords = ["docker", "home-assistant", "api"] +requires-python = ">=3.11.0" + +[project.urls] +"Homepage" = "https://www.home-assistant.io/" +"Source Code" = "https://github.com/home-assistant/supervisor" +"Bug Reports" = "https://github.com/home-assistant/supervisor/issues" +"Docs: Dev" = "https://developers.home-assistant.io/" +"Discord" = "https://www.home-assistant.io/join-chat/" +"Forum" = "https://community.home-assistant.io/" + +[tool.setuptools] +platforms = ["any"] +zip-safe = false +include-package-data = true + +[tool.setuptools.packages.find] +include = ["supervisor*"] + +[tool.pylint.MAIN] +py-version = "3.11" +# Use a conservative default here; 2 should speed up most setups and not hurt +# any too bad. Override on command line as appropriate. +jobs = 2 +persistent = false +extension-pkg-allow-list = ["ciso8601"] + +[tool.pylint.BASIC] +class-const-naming-style = "any" +good-names = ["id", "i", "j", "k", "ex", "Run", "_", "fp", "T", "os"] + +[tool.pylint."MESSAGES CONTROL"] +# Reasons disabled: +# format - handled by black +# abstract-method - with intro of async there are always methods missing +# cyclic-import - doesn't test if both import on load +# duplicate-code - unavoidable +# locally-disabled - it spams too much +# too-many-* - are not enforced for the sake of readability +# too-few-* - same as too-many-* +# unused-argument - generic callbacks and setup methods create a lot of warnings +disable = [ + "format", + "abstract-method", + "cyclic-import", + "duplicate-code", + "locally-disabled", + "no-else-return", + "not-context-manager", + "too-few-public-methods", + "too-many-arguments", + "too-many-branches", + "too-many-instance-attributes", + "too-many-lines", + "too-many-locals", + "too-many-public-methods", + "too-many-return-statements", + "too-many-statements", + "unused-argument", + "consider-using-with", +] + +[tool.pylint.REPORTS] +score = false + +[tool.pylint.TYPECHECK] +ignored-modules = ["distutils"] + +[tool.pylint.FORMAT] +expected-line-ending-format = "LF" + +[tool.pylint.EXCEPTIONS] +overgeneral-exceptions = ["builtins.BaseException", "builtins.Exception"] + +[tool.pytest.ini_options] +testpaths = ["tests"] +norecursedirs = [".git"] +log_format = "%(asctime)s.%(msecs)03d %(levelname)-8s %(threadName)s %(name)s:%(filename)s:%(lineno)s %(message)s" +log_date_format = "%Y-%m-%d %H:%M:%S" +asyncio_mode = "auto" +filterwarnings = [ + "error", + "ignore:pkg_resources is deprecated as an API:DeprecationWarning:dirhash", + "ignore::pytest.PytestUnraisableExceptionWarning", +] + +[tool.isort] +multi_line_output = 3 +include_trailing_comma = true +force_grid_wrap = 0 +line_length = 88 +indent = " " +force_sort_within_sections = true +sections = ["FUTURE", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"] +default_section = "THIRDPARTY" +forced_separate = "tests" +combine_as_imports = true +use_parentheses = true +known_first_party = ["supervisor", "tests"] diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index 3a7f04a0b..000000000 --- a/pytest.ini +++ /dev/null @@ -1,6 +0,0 @@ -[pytest] -asyncio_mode = auto -filterwarnings = - error - ignore:pkg_resources is deprecated as an API:DeprecationWarning:dirhash - ignore::pytest.PytestUnraisableExceptionWarning diff --git a/setup.cfg b/setup.cfg index 27e468bdc..23eb4307b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,17 +1,3 @@ -[isort] -multi_line_output = 3 -include_trailing_comma=True -force_grid_wrap=0 -line_length=88 -indent = " " -force_sort_within_sections = true -sections = FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER -default_section = THIRDPARTY -forced_separate = tests -combine_as_imports = true -use_parentheses = true -known_first_party = supervisor,tests - [flake8] exclude = .venv,.git,.tox,docs,venv,bin,lib,deps,build doctests = True diff --git a/setup.py b/setup.py index 502d3993e..a5df554fe 100644 --- a/setup.py +++ b/setup.py @@ -1,48 +1,27 @@ """Home Assistant Supervisor setup.""" +from pathlib import Path +import re + from setuptools import setup -from supervisor.const import SUPERVISOR_VERSION +RE_SUPERVISOR_VERSION = re.compile(r"^SUPERVISOR_VERSION =\s*(.+)$") + +SUPERVISOR_DIR = Path(__file__).parent +REQUIREMENTS_FILE = SUPERVISOR_DIR / "requirements.txt" +CONST_FILE = SUPERVISOR_DIR / "supervisor/const.py" + +REQUIREMENTS = REQUIREMENTS_FILE.read_text(encoding="utf-8") +CONSTANTS = CONST_FILE.read_text(encoding="utf-8") + + +def _get_supervisor_version(): + for line in CONSTANTS.split("/n"): + if match := RE_SUPERVISOR_VERSION.match(line): + return match.group(1) + return "99.9.9dev" + setup( - name="Supervisor", - version=SUPERVISOR_VERSION, - license="BSD License", - author="The Home Assistant Authors", - author_email="hello@home-assistant.io", - url="https://home-assistant.io/", - description=("Open-source private cloud os for Home-Assistant" " based on HassOS"), - long_description=( - "A maintainless private cloud operator system that" - "setup a Home-Assistant instance. Based on HassOS" - ), - keywords=["docker", "home-assistant", "api"], - zip_safe=False, - platforms="any", - packages=[ - "supervisor.addons", - "supervisor.api", - "supervisor.backups", - "supervisor.dbus.network", - "supervisor.dbus.network.setting", - "supervisor.dbus", - "supervisor.discovery.services", - "supervisor.discovery", - "supervisor.docker", - "supervisor.homeassistant", - "supervisor.host", - "supervisor.jobs", - "supervisor.misc", - "supervisor.plugins", - "supervisor.resolution.checks", - "supervisor.resolution.evaluations", - "supervisor.resolution.fixups", - "supervisor.resolution", - "supervisor.security", - "supervisor.services.modules", - "supervisor.services", - "supervisor.store", - "supervisor.utils", - "supervisor", - ], - include_package_data=True, + version=_get_supervisor_version(), + dependencies=REQUIREMENTS.split("/n"), ) diff --git a/tests/resolution/evaluation/test_evaluate_operating_system.py b/tests/resolution/evaluation/test_evaluate_operating_system.py index d2234b80c..53d26d66c 100644 --- a/tests/resolution/evaluation/test_evaluate_operating_system.py +++ b/tests/resolution/evaluation/test_evaluate_operating_system.py @@ -17,7 +17,7 @@ async def test_evaluation(coresys: CoreSys): assert operating_system.reason not in coresys.resolution.unsupported - coresys.host._info = MagicMock(operating_system="unsupported") + coresys.host._info = MagicMock(operating_system="unsupported", timezone=None) await operating_system() assert operating_system.reason in coresys.resolution.unsupported @@ -26,7 +26,7 @@ async def test_evaluation(coresys: CoreSys): assert operating_system.reason not in coresys.resolution.unsupported coresys.os._available = False - coresys.host._info = MagicMock(operating_system=SUPPORTED_OS[0]) + coresys.host._info = MagicMock(operating_system=SUPPORTED_OS[0], timezone=None) await operating_system() assert operating_system.reason not in coresys.resolution.unsupported diff --git a/tests/resolution/evaluation/test_evaluate_os_agent.py b/tests/resolution/evaluation/test_evaluate_os_agent.py index 34665ae96..90b6699fc 100644 --- a/tests/resolution/evaluation/test_evaluate_os_agent.py +++ b/tests/resolution/evaluation/test_evaluate_os_agent.py @@ -15,7 +15,7 @@ async def test_evaluation(coresys: CoreSys): assert agent.reason not in coresys.resolution.unsupported - coresys._host = MagicMock() + coresys._host = MagicMock(info=MagicMock(timezone=None)) coresys.host.features = [HostFeature.HOSTNAME] await agent() diff --git a/tests/resolution/evaluation/test_evaluate_systemd.py b/tests/resolution/evaluation/test_evaluate_systemd.py index 0bd1dd750..5bbc37045 100644 --- a/tests/resolution/evaluation/test_evaluate_systemd.py +++ b/tests/resolution/evaluation/test_evaluate_systemd.py @@ -15,7 +15,7 @@ async def test_evaluation(coresys: CoreSys): assert systemd.reason not in coresys.resolution.unsupported - coresys._host = MagicMock() + coresys._host = MagicMock(info=MagicMock(timezone=None)) coresys.host.features = [HostFeature.HOSTNAME] await systemd()