From 6212b211365e1a221918c2cb4689e54db6a418b9 Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Wed, 6 Sep 2023 18:08:49 +0200 Subject: [PATCH] Maintenance: Update to Python 3.10 --- .github/workflows/main.yaml | 6 +++--- .pre-commit-config.yaml | 5 ++++- .readthedocs.yml | 2 +- CHANGES.rst | 2 ++ Dockerfile | 4 ++-- crate/operator/config.py | 2 +- docs/source/conf.py | 2 +- docs/source/crate_operator_ext.py | 2 +- docs/source/development.rst | 6 +++--- setup.cfg | 2 ++ setup.py | 7 ++++--- tests/utils.py | 4 ++-- 12 files changed, 26 insertions(+), 18 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 526c08c9..d73afc03 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -19,7 +19,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: 3.8 + python-version: "3.10" - name: Install dependencies run: | python -m pip install --upgrade pip pre-commit @@ -46,7 +46,7 @@ jobs: uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: 3.8 + python-version: "3.10" - name: Install dependencies run: | python -m pip install ".[docs]" @@ -65,7 +65,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: 3.8 + python-version: "3.10" - name: Install dependencies run: | python -m pip install --upgrade -e ".[testing]" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 86ffc3c3..7e958f92 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,9 +18,12 @@ repos: hooks: - id: isort - repo: https://github.com/pre-commit/mirrors-mypy - rev: "v0.770" + rev: "v0.981" hooks: - id: mypy + additional_dependencies: + - types-docutils + - types-PyYAML - repo: https://github.com/adrienverge/yamllint rev: "v1.25.0" hooks: diff --git a/.readthedocs.yml b/.readthedocs.yml index 93c5392d..09bbbb01 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -2,7 +2,7 @@ build: os: "ubuntu-22.04" tools: - python: "3.9" + python: "3.10" python: install: diff --git a/CHANGES.rst b/CHANGES.rst index 0eaa37d4..c66d0447 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -19,6 +19,8 @@ Unreleased * Change sql_exporter ``min_interval`` to 60s to avoid scraping every 15s. +* Updated Python version to ``3.10``. + 2.42.0 (2024-10-02) ------------------- diff --git a/Dockerfile b/Dockerfile index 1bfde560..5a30e53c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Build container -FROM python:3.8-slim AS build +FROM python:3.10-slim AS build RUN mkdir -pv /src @@ -14,7 +14,7 @@ RUN python -m pip install -U setuptools==70.3.0 && \ # Run container -FROM python:3.8-slim +FROM python:3.10-slim LABEL license="Apache License 2.0" \ maintainer="Crate.IO GmbH " \ diff --git a/crate/operator/config.py b/crate/operator/config.py index 4d2be682..07c283e6 100644 --- a/crate/operator/config.py +++ b/crate/operator/config.py @@ -472,7 +472,7 @@ def env(self, name: str, *, default=UNDEFINED) -> str: if default is UNDEFINED: # raise from None - so that the traceback of the original # exception (KeyError) is not printed - # https://docs.python.org/3.8/reference/simple_stmts.html#the-raise-statement + # https://docs.python.org/3.10/reference/simple_stmts.html#the-raise-statement raise ConfigurationError( f"Required environment variable '{full_name}' is not set." ) from None diff --git a/docs/source/conf.py b/docs/source/conf.py index 397d8f71..90b1be46 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -78,6 +78,6 @@ "bitmath": ("https://bitmath.readthedocs.io/en/stable/", None), "cratedb": ("https://crate.io/docs/crate/reference/en/stable/", None), "kopf": ("https://kopf.readthedocs.io/en/stable/", None), - "python": ("https://docs.python.org/3.8/", None), + "python": ("https://docs.python.org/3.10/", None), } always_document_param_types = True diff --git a/docs/source/crate_operator_ext.py b/docs/source/crate_operator_ext.py index 92e865ac..46395258 100644 --- a/docs/source/crate_operator_ext.py +++ b/docs/source/crate_operator_ext.py @@ -47,7 +47,7 @@ def run_apidoc(_): def missing_reference( app: Sphinx, env: BuildEnvironment, node: pending_xref, contnode: Element -) -> Element: +) -> None: """ Remove or resolve references to third party packages. diff --git a/docs/source/development.rst b/docs/source/development.rst index e41bbb7d..780e8462 100644 --- a/docs/source/development.rst +++ b/docs/source/development.rst @@ -4,7 +4,7 @@ Working on the operator Local installation ------------------ -The ``crate-operator`` package requires **Python 3.8**. +The ``crate-operator`` package requires **Python 3.10**. It is recommended to use a virtual environment to the operator and its dependencies for local development. @@ -17,7 +17,7 @@ dependencies for local development. .. code-block:: console - $ python3.8 -m venv env + $ python3.10 -m venv env $ source env/bin/activate (env)$ python -m pip install -e . @@ -57,7 +57,7 @@ test dependencies. This is typically done inside a Python virtual environment: .. code-block:: console - $ python3.8 -m venv env + $ python3.10 -m venv env $ source env/bin/activate (env)$ python -m pip install -e '.[testing]' Successfully installed ... crate-operator ... diff --git a/setup.cfg b/setup.cfg index 9db94732..5cb6e4d7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -4,6 +4,8 @@ universal = 1 [mypy] ignore_missing_imports = true namespace_packages = true +mypy_path = . +explicit_package_bases = True [flake8] max-line-length = 88 diff --git a/setup.py b/setup.py index 5dfac661..befb0837 100644 --- a/setup.py +++ b/setup.py @@ -57,6 +57,7 @@ def read(path: str) -> str: "prometheus_client==0.21.0", "aiohttp==3.10.10", "wrapt==1.17.0", + "python-json-logger==2.0.7", ], extras_require={ "docs": [ @@ -76,15 +77,15 @@ def read(path: str) -> str: "black==22.3.0", "flake8==3.8.4", "isort==5.12.0", - "mypy==0.770", + "mypy==0.981", ], }, - python_requires=">=3.8", + python_requires=">=3.10", classifiers=[ "Development Status :: 5 - Production/Stable", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.10", ], use_scm_version=True, ) diff --git a/tests/utils.py b/tests/utils.py index 093cd8a4..8bb087f9 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -449,7 +449,7 @@ async def cluster_routing_allocation_enable_equals( async def was_notification_sent( - mock_send_notification: mock.AsyncMock, call: mock.call + mock_send_notification: mock.AsyncMock, call: mock._Call ): if mock_send_notification.call_count == 0: return False @@ -469,7 +469,7 @@ async def is_cronjob_schedule_matching( async def mocked_coro_func_called_with( - mocked_coro_func: mock.AsyncMock, call: mock.call + mocked_coro_func: mock.AsyncMock, call: mock._Call ) -> bool: if mocked_coro_func.call_count == 0: return False