From 38050a269a5297a4b28bcec133054172b460b336 Mon Sep 17 00:00:00 2001 From: Claus Holbech Date: Mon, 29 Jul 2024 16:46:47 +0200 Subject: [PATCH] Bump: Minimum Python version 3.10 (#4276) --- .github/workflows/pull-request-management.yml | 3 +-- .sonarcloud.properties | 2 +- ansible_collections/arista/avd/README.md | 2 +- .../installation/collection-installation.md | 2 +- .../arista/avd/docs/release-notes/5.x.x.md | 2 +- .../avd/plugins/action/verify_requirements.py | 6 +++--- ansible_collections/arista/avd/tests/config.yml | 2 +- python-avd/pyproject.toml | 4 +--- .../metaschema/meta_schema_model.py | 7 ++----- .../generate_docs/test_mdtabsgen.py | 14 ++++++-------- .../metaschema/test_meta_schema_model.py | 17 +++++++---------- python-avd/tox.ini | 2 -- 12 files changed, 25 insertions(+), 38 deletions(-) diff --git a/.github/workflows/pull-request-management.yml b/.github/workflows/pull-request-management.yml index a9af5ba85bf..1102fe7ddd6 100644 --- a/.github/workflows/pull-request-management.yml +++ b/.github/workflows/pull-request-management.yml @@ -95,7 +95,6 @@ jobs: fail-fast: true matrix: python_version: - - "3.9" - "3.10" - "3.11" - "3.12" @@ -482,7 +481,7 @@ jobs: needs.file-changes.outputs.pyavd == 'true' strategy: matrix: - python: ["3.9", "3.10", "3.11", "3.12"] + python: ["3.10", "3.11", "3.12"] steps: - name: 'Set environment variables' run: | diff --git a/.sonarcloud.properties b/.sonarcloud.properties index 6e3907878b7..3fc82dee090 100644 --- a/.sonarcloud.properties +++ b/.sonarcloud.properties @@ -1,5 +1,5 @@ # Python version -sonar.python.version=3.9, 3.10, 3.11, 3.12 +sonar.python.version=3.10, 3.11, 3.12 # Exclude tests from source sonar.exclusions=python-avd/tests/** # Path to tests diff --git a/ansible_collections/arista/avd/README.md b/ansible_collections/arista/avd/README.md index 73f88010a59..055487a67c0 100644 --- a/ansible_collections/arista/avd/README.md +++ b/ansible_collections/arista/avd/README.md @@ -21,7 +21,7 @@ AVD Documentation: The AVD collection has the following requirements: -- Python 3.9 or above +- Python 3.10 or above - Ansible Core 2.15.0 to 2.17.x - [Additional Python Dependencies](#additional-python-dependencies) - Modify the `ansible.cfg` file to support additional Jinja2 extensions diff --git a/ansible_collections/arista/avd/docs/installation/collection-installation.md b/ansible_collections/arista/avd/docs/installation/collection-installation.md index 69a4b81eda3..d34c0b24338 100644 --- a/ansible_collections/arista/avd/docs/installation/collection-installation.md +++ b/ansible_collections/arista/avd/docs/installation/collection-installation.md @@ -8,7 +8,7 @@ ## Installation workflow -- Install [Python](https://www.python.org/downloads/) **3.9** or later +- Install [Python](https://www.python.org/downloads/) **3.10** or later - Install [arista.avd](#install-collection-from-ansible-galaxy) collection including Python requirements. - Modify `ansible.cfg` file to support additional [jinja2 extensions](#ansible-configuration-file) diff --git a/ansible_collections/arista/avd/docs/release-notes/5.x.x.md b/ansible_collections/arista/avd/docs/release-notes/5.x.x.md index 1dc041f4dbb..b37960008c2 100644 --- a/ansible_collections/arista/avd/docs/release-notes/5.x.x.md +++ b/ansible_collections/arista/avd/docs/release-notes/5.x.x.md @@ -16,7 +16,7 @@ title: Release Notes for AVD 5.x.x ### Changes to requirements -TODO +- AVD v.5.0.0 requires Python version 3.10 or newer. ### Data model changes from "dict-of-dicts" to "list-of-dicts" diff --git a/ansible_collections/arista/avd/plugins/action/verify_requirements.py b/ansible_collections/arista/avd/plugins/action/verify_requirements.py index 2e00b3f975e..08de325de62 100644 --- a/ansible_collections/arista/avd/plugins/action/verify_requirements.py +++ b/ansible_collections/arista/avd/plugins/action/verify_requirements.py @@ -25,8 +25,8 @@ except ImportError: HAS_PACKAGING = False -# Python >= 3.9 -MIN_PYTHON_SUPPORTED_VERSION = (3, 9) +MIN_PYTHON_SUPPORTED_VERSION = (3, 10) +DEPRECATE_MIN_PYTHON_SUPPORTED_VERSION = False def _validate_python_version(info: dict, result: dict) -> bool: @@ -54,7 +54,7 @@ def _validate_python_version(info: dict, result: dict) -> bool: display.error(f"Python Version running {running_version} - Minimum Version required is {min_version}", False) return False # Keeping this for next deprecation adjust the message as required - elif sys.version_info[:2] == MIN_PYTHON_SUPPORTED_VERSION: + elif DEPRECATE_MIN_PYTHON_SUPPORTED_VERSION and sys.version_info[:2] == MIN_PYTHON_SUPPORTED_VERSION: result.setdefault("deprecations", []).append( { "msg": ( diff --git a/ansible_collections/arista/avd/tests/config.yml b/ansible_collections/arista/avd/tests/config.yml index c26ea59662b..6fe2c43ad80 100644 --- a/ansible_collections/arista/avd/tests/config.yml +++ b/ansible_collections/arista/avd/tests/config.yml @@ -1,3 +1,3 @@ --- modules: - python_requires: ">=3.9" + python_requires: ">=3.10" diff --git a/python-avd/pyproject.toml b/python-avd/pyproject.toml index 4fc9a57015f..3ec659942fc 100644 --- a/python-avd/pyproject.toml +++ b/python-avd/pyproject.toml @@ -10,7 +10,6 @@ classifiers = [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "Programming Language :: Python", - "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", @@ -18,7 +17,7 @@ classifiers = [ "Topic :: Software Development :: Testing", ] keywords = ["pyavd"] -requires-python = ">=3.9" +requires-python = ">=3.10" dependencies = [ "aristaproto>=0.1.1", "cryptography>=38.0.4", @@ -56,7 +55,6 @@ requires = [ "pyyaml>=6.0.0", "mkdocstrings[python]", "pydantic>=2.3.0", - "eval-type-backport>=0.2.0", # Only needed for 3.9 "cryptography>=38.0.4", "aristaproto>=0.1.1", ] diff --git a/python-avd/schema_tools/metaschema/meta_schema_model.py b/python-avd/schema_tools/metaschema/meta_schema_model.py index ed8a92952cb..bd672edd681 100644 --- a/python-avd/schema_tools/metaschema/meta_schema_model.py +++ b/python-avd/schema_tools/metaschema/meta_schema_model.py @@ -6,7 +6,7 @@ from abc import ABC from enum import Enum from functools import cached_property -from typing import Annotated, Any, ClassVar, Generator, List, Literal, Union +from typing import Annotated, Any, ClassVar, Generator, List, Literal from pydantic import BaseModel, ConfigDict, Field, constr @@ -573,8 +573,5 @@ def _path(self) -> list[str]: return [] -# Workaround for tox until Python 3.9 is dropped -# https://github.com/microsoft/pyright/issues/4615#issuecomment-1426685471 -AvdSchemaField = Union[AvdSchemaInt, AvdSchemaBool, AvdSchemaStr, AvdSchemaList, AvdSchemaDict] -# AvdSchemaField = AvdSchemaInt | AvdSchemaBool | AvdSchemaStr | AvdSchemaList | AvdSchemaDict +AvdSchemaField = AvdSchemaInt | AvdSchemaBool | AvdSchemaStr | AvdSchemaList | AvdSchemaDict """Alias for any of the AvdSchema field types""" diff --git a/python-avd/tests/schema_tools/generate_docs/test_mdtabsgen.py b/python-avd/tests/schema_tools/generate_docs/test_mdtabsgen.py index 7ece8b0d141..2691a46901f 100644 --- a/python-avd/tests/schema_tools/generate_docs/test_mdtabsgen.py +++ b/python-avd/tests/schema_tools/generate_docs/test_mdtabsgen.py @@ -2,21 +2,19 @@ # Use of this source code is governed by the Apache License 2.0 # that can be found in the LICENSE file. from pathlib import Path -from sys import path, version_info +from sys import path from unittest.mock import patch import pytest -if version_info >= (3, 10): - # Override global path to load schema from source instead of any installed version. - # Avoids to load from pyavd to avoid relying on pyavd vendor things being generated. - path.insert(0, str(Path(__file__).parents[3])) +# Override global path to load schema from source instead of any installed version. +# Avoids to load from pyavd to avoid relying on pyavd vendor things being generated. +path.insert(0, str(Path(__file__).parents[3])) - from schema_tools.generate_docs.mdtabsgen import get_md_tabs - from schema_tools.metaschema.meta_schema_model import AristaAvdSchema +from schema_tools.generate_docs.mdtabsgen import get_md_tabs +from schema_tools.metaschema.meta_schema_model import AristaAvdSchema -@pytest.mark.skipif(version_info < (3, 10), reason="Our Pydantic models require minimum Python3.10") @pytest.mark.parametrize("table_name", ["network-services-multicast-settings"]) def test_get_md_tabs(table_name: str, schema_store, artifacts_path, output_path): """ diff --git a/python-avd/tests/schema_tools/metaschema/test_meta_schema_model.py b/python-avd/tests/schema_tools/metaschema/test_meta_schema_model.py index fc2f6a07cd7..4e6d9de2e1d 100644 --- a/python-avd/tests/schema_tools/metaschema/test_meta_schema_model.py +++ b/python-avd/tests/schema_tools/metaschema/test_meta_schema_model.py @@ -3,20 +3,18 @@ # that can be found in the LICENSE file. import json from pathlib import Path -from sys import path, version_info +from sys import path -import pytest import yaml -if version_info >= (3, 10): - # Override global path to load schema from source instead of any installed version. - # Avoids to load from pyavd to avoid relying on pyavd vendor things being generated. - path.insert(0, str(Path(__file__).parents[3])) +# Override global path to load schema from source instead of any installed version. +# Avoids to load from pyavd to avoid relying on pyavd vendor things being generated. +path.insert(0, str(Path(__file__).parents[3])) - from schema_tools.metaschema.meta_schema_model import AristaAvdSchema - from schema_tools.store import create_store +from schema_tools.metaschema.meta_schema_model import AristaAvdSchema +from schema_tools.store import create_store - raw_schema = create_store()["eos_designs"] +raw_schema = create_store()["eos_designs"] class NoAliasDumper(yaml.Dumper): @@ -26,7 +24,6 @@ def ignore_aliases(self, _): return True -@pytest.mark.skipif(version_info < (3, 10), reason="Our Pydantic models require minimum Python3.10") def test_pydantic_dump_matches_original_yaml(): """ Loads the schema _without_ resolving the $ref and then dumps the schema again as json. diff --git a/python-avd/tox.ini b/python-avd/tox.ini index ca22a4f4f89..114169d0d7f 100644 --- a/python-avd/tox.ini +++ b/python-avd/tox.ini @@ -1,6 +1,5 @@ [tox] env_list = - py39 py310 py311 py312 @@ -12,7 +11,6 @@ depends = [gh-actions] python = - 3.9: py39 3.10: py310 3.11: coverage, report 3.12: py312