Skip to content

Commit

Permalink
Bump: Minimum Python version 3.10 (#4276)
Browse files Browse the repository at this point in the history
  • Loading branch information
ClausHolbechArista authored Jul 29, 2024
1 parent 32cd355 commit 38050a2
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 38 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/pull-request-management.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ jobs:
fail-fast: true
matrix:
python_version:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
Expand Down Expand Up @@ -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: |
Expand Down
2 changes: 1 addition & 1 deletion .sonarcloud.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion ansible_collections/arista/avd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion ansible_collections/arista/avd/docs/release-notes/5.x.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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": (
Expand Down
2 changes: 1 addition & 1 deletion ansible_collections/arista/avd/tests/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
modules:
python_requires: ">=3.9"
python_requires: ">=3.10"
4 changes: 1 addition & 3 deletions python-avd/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ 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",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Software Development :: Testing",
]
keywords = ["pyavd"]
requires-python = ">=3.9"
requires-python = ">=3.10"
dependencies = [
"aristaproto>=0.1.1",
"cryptography>=38.0.4",
Expand Down Expand Up @@ -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",
]
Expand Down
7 changes: 2 additions & 5 deletions python-avd/schema_tools/metaschema/meta_schema_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"""
14 changes: 6 additions & 8 deletions python-avd/tests/schema_tools/generate_docs/test_mdtabsgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
17 changes: 7 additions & 10 deletions python-avd/tests/schema_tools/metaschema/test_meta_schema_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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.
Expand Down
2 changes: 0 additions & 2 deletions python-avd/tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[tox]
env_list =
py39
py310
py311
py312
Expand All @@ -12,7 +11,6 @@ depends =

[gh-actions]
python =
3.9: py39
3.10: py310
3.11: coverage, report
3.12: py312
Expand Down

0 comments on commit 38050a2

Please sign in to comment.