Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python version and dependencies bumping #10

Merged
merged 5 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.6, 3.7, 3.8, 3.9, '3.10']
python: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v2
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions napalm_servertech_pro2/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""napalm-servertech-pro2 package."""

from napalm_servertech_pro2.pro2 import PRO2Driver # noqa

__all__ = ("PRO2Driver",)
5 changes: 3 additions & 2 deletions napalm_servertech_pro2/pro2.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""NAPALM driver for ServerTech PRO2 PDUs"""

import json

import requests
Expand Down Expand Up @@ -175,7 +176,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("-", ":"),
Expand All @@ -189,7 +190,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", ""),
}
Expand Down
2 changes: 1 addition & 1 deletion napalm_servertech_pro2/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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.*
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@
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",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS",
],
Expand Down
6 changes: 3 additions & 3 deletions tests/utils/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 3 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py3{6,7,8,9,10},black,pylama
envlist = py3{8,9,10,11,12},black,pylama
skip_missing_interpreters = true

[testenv]
Expand All @@ -15,14 +15,14 @@ commands =
deps =
-rrequirements-dev.txt

basepython = python3.10
basepython = python3.12
commands =
black --check .

[testenv:pylama]
deps =
-rrequirements-dev.txt

basepython = python3.10
basepython = python3.12
commands =
pylama .
Loading