From 95a1800edf6ac6a3acbd76a120692cc9a4c3a396 Mon Sep 17 00:00:00 2001 From: Antoine Meillet <antoine.meillet@gmail.com> Date: Wed, 7 Feb 2024 12:03:29 +0100 Subject: [PATCH 1/5] Drop end-of-life Python versions As per the release cycle (https://devguide.python.org/versions/): * Python 3.6 EOL since end of 2021 * Python 3.7 EOL since end of 2022 Dropping support for those in future releases. --- .github/workflows/ci.yaml | 2 +- setup.py | 3 --- tox.ini | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ee81aa4..9ea108e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python: [3.6, 3.7, 3.8, 3.9, '3.10'] + python: [3.8, 3.9, '3.10'] steps: - uses: actions/checkout@v2 diff --git a/setup.py b/setup.py index 761d683..33ed92c 100644 --- a/setup.py +++ b/setup.py @@ -23,11 +23,8 @@ long_description_content_type="text/markdown", classifiers=[ "Topic :: Utilities", - "Programming Language :: Python :: 3.4", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", diff --git a/tox.ini b/tox.ini index 1b07fb7..23da672 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py3{6,7,8,9,10},black,pylama +envlist = py3{8,9,10},black,pylama skip_missing_interpreters = true [testenv] From c0f39cada245f02bfd175cda9be5cea3f7478fee Mon Sep 17 00:00:00 2001 From: Antoine Meillet <antoine.meillet@gmail.com> Date: Wed, 7 Feb 2024 15:20:14 +0100 Subject: [PATCH 2/5] Return uptime as float The base napalm model expects uptime to be a float. --- napalm_servertech_pro2/utils.py | 2 +- tests/utils/test_utils.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/napalm_servertech_pro2/utils.py b/napalm_servertech_pro2/utils.py index 2b1527d..957804f 100644 --- a/napalm_servertech_pro2/utils.py +++ b/napalm_servertech_pro2/utils.py @@ -13,7 +13,7 @@ def convert_uptime(uptime): ) if not m: raise ValueError("uptime string was not recognized: regex did not match") - return ( + return float( int(m.group("days")) * 86400 + int(m.group("hours")) * 3600 + int(m.group("minutes")) * 60 diff --git a/tests/utils/test_utils.py b/tests/utils/test_utils.py index f396a19..5a97a2b 100644 --- a/tests/utils/test_utils.py +++ b/tests/utils/test_utils.py @@ -6,13 +6,13 @@ def test_convert_uptime(): uptime = "11 days 4 hours 8 minutes 6 seconds" - assert utils.convert_uptime(uptime) == 965286 + assert utils.convert_uptime(uptime) == 965286.0 uptime = "133 days 1 hour 12 minutes 15 seconds" - assert isinstance(utils.convert_uptime(uptime), int) + assert isinstance(utils.convert_uptime(uptime), float) uptime = "0 days 0 hours 0 minutes 1 second" - assert utils.convert_uptime(uptime) == 1 + assert utils.convert_uptime(uptime) == 1.0 with pytest.raises(ValueError): utils.convert_uptime("hello") From bb0e4c330345f4c0c4db84247af63785a0edb63e Mon Sep 17 00:00:00 2001 From: Antoine Meillet <antoine.meillet@gmail.com> Date: Wed, 7 Feb 2024 15:22:10 +0100 Subject: [PATCH 3/5] Speed is a float in the napalm model Just like uptime, the napalm base models expects speed to be a float, so we will just be conform --- napalm_servertech_pro2/pro2.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/napalm_servertech_pro2/pro2.py b/napalm_servertech_pro2/pro2.py index a11b14b..d92cf88 100644 --- a/napalm_servertech_pro2/pro2.py +++ b/napalm_servertech_pro2/pro2.py @@ -175,7 +175,7 @@ def get_interfaces(self): { "id": "NET", "name": "management", - "speed": int(net["speed"].split(" ")[0]), + "speed": float(net["speed"].split(" ")[0]), "status": "Normal" if net["link"] == "Up" else False, "state": "On", "mac_address": net["ethernet_mac_address"].replace("-", ":"), @@ -189,7 +189,7 @@ def get_interfaces(self): "is_enabled": True if port["state"] == "On" else False, "description": port["name"], "last_flapped": -1.0, - "speed": port.get("speed", 0), + "speed": port.get("speed", 0.0), "mtu": port.get("mtu", 0), "mac_address": port.get("mac_address", ""), } From c671579876789fb098838955f0d1ccf23e81ee22 Mon Sep 17 00:00:00 2001 From: Antoine Meillet <antoine.meillet@gmail.com> Date: Wed, 7 Feb 2024 15:26:22 +0100 Subject: [PATCH 4/5] Bump dependencies Includes black-related formatting changes. --- napalm_servertech_pro2/__init__.py | 1 + napalm_servertech_pro2/pro2.py | 1 + requirements-dev.txt | 10 +++++----- requirements.txt | 6 +++--- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/napalm_servertech_pro2/__init__.py b/napalm_servertech_pro2/__init__.py index 7c0daf7..2126a2e 100644 --- a/napalm_servertech_pro2/__init__.py +++ b/napalm_servertech_pro2/__init__.py @@ -1,4 +1,5 @@ """napalm-servertech-pro2 package.""" + from napalm_servertech_pro2.pro2 import PRO2Driver # noqa __all__ = ("PRO2Driver",) diff --git a/napalm_servertech_pro2/pro2.py b/napalm_servertech_pro2/pro2.py index d92cf88..7cac559 100644 --- a/napalm_servertech_pro2/pro2.py +++ b/napalm_servertech_pro2/pro2.py @@ -1,4 +1,5 @@ """NAPALM driver for ServerTech PRO2 PDUs""" + import json import requests diff --git a/requirements-dev.txt b/requirements-dev.txt index 492c824..7d87b7e 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,5 +1,5 @@ -black==21.5b1 -pylama==7.7.1 -pylint==2.8.2 -pytest==6.2.4 -tox==3.23.1 +black==24.1.1 +pylama==8.4.1 +pylint==3.0.3 +pytest==7.3.1 +tox==4.12.1 diff --git a/requirements.txt b/requirements.txt index d55a1b9..807e76a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -napalm>=3.3.0 -netaddr==0.8.0 -requests==2.25.* +napalm>=4.1.0 +netaddr==0.10.1 +requests==2.31.* From 4f2d2b1a2fd00880dc563ffd3765fdc28068d8e6 Mon Sep 17 00:00:00 2001 From: Antoine Meillet <antoine.meillet@gmail.com> Date: Wed, 7 Feb 2024 15:26:46 +0100 Subject: [PATCH 5/5] Support latest Python versions Python 3.11 and 3.12 were released since the last commits. --- .github/workflows/ci.yaml | 27 +++++++++++++++++++++------ setup.py | 2 ++ tox.ini | 6 +++--- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9ea108e..4db442f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -5,11 +5,11 @@ on: [push, pull_request] jobs: # https://docs.github.com/en/actions/guides/building-and-testing-python#testing-your-code run-tests: - name: Run tests and linters (with tox) + name: Run tests (with tox) runs-on: ubuntu-latest strategy: matrix: - python: [3.8, 3.9, '3.10'] + python: ["3.8", "3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v2 @@ -24,6 +24,21 @@ jobs: - name: Test against listed Python versions # Run tox using the version of Python in `PATH` run: tox -e py + + run-lint: + name: Run linters (with tox) + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: "3.12" + - name: Install Tox and any other packages + run: | + pip install tox + pip install -r requirements.txt -r requirements-dev.txt - name: Run black run: tox -e black - name: Run pylama @@ -38,10 +53,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Setup Python 3.10 + - name: Setup Python 3.12 uses: actions/setup-python@v2 with: - python-version: '3.10' + python-version: '3.12' - name: Install pypa/build run: | python -m pip install build --user @@ -62,10 +77,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Setup Python 3.10 + - name: Setup Python 3.12 uses: actions/setup-python@v2 with: - python-version: '3.10' + python-version: '3.12' - name: Install pypa/build run: | python -m pip install build --user diff --git a/setup.py b/setup.py index 33ed92c..5112a86 100644 --- a/setup.py +++ b/setup.py @@ -28,6 +28,8 @@ "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Operating System :: POSIX :: Linux", "Operating System :: MacOS", ], diff --git a/tox.ini b/tox.ini index 23da672..7cdce8f 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py3{8,9,10},black,pylama +envlist = py3{8,9,10,11,12},black,pylama skip_missing_interpreters = true [testenv] @@ -15,7 +15,7 @@ commands = deps = -rrequirements-dev.txt -basepython = python3.10 +basepython = python3.12 commands = black --check . @@ -23,6 +23,6 @@ commands = deps = -rrequirements-dev.txt -basepython = python3.10 +basepython = python3.12 commands = pylama .