Skip to content

Commit cf79b8f

Browse files
Fix GitHub CI, use 3.11, 3.12 and 3.13 and fix pylint errors
Signed-off-by: Bernhard Kaindl <[email protected]>
1 parent 270ccd1 commit cf79b8f

23 files changed

+100
-184
lines changed

Diff for: .github/workflows/main.yml

+4-19
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ jobs:
2828
fail-fast: false
2929
matrix:
3030
include:
31-
- python-version: '3.6'
32-
os: ubuntu-20.04
33-
- python-version: '3.10'
34-
os: ubuntu-22.04
3531
- python-version: '3.11'
3632
os: ubuntu-22.04
33+
- python-version: '3.12'
34+
os: ubuntu-22.04
35+
- python-version: '3.13'
36+
os: ubuntu-22.04
3737
runs-on: ${{ matrix.os }}
3838
steps:
3939
- uses: actions/checkout@v4
@@ -58,21 +58,6 @@ jobs:
5858
pip install 'virtualenv<20.22' 'tox==4.5.1' tox-gh-actions
5959
tox --workdir .github/workflows/.tox --recreate
6060
61-
# tox >= 4.0.0 is needed for using optional-dependencies from pyproject.toml, which is
62-
# is not available for python <= 3.6, so use the python3.8 of Ubuntu-20.04 to install it:
63-
- name: Run tox for 3.6 and 3.8 on ${{ matrix.os }}'s 3.8 to get 'extras' from pyproject.toml)
64-
if: ${{ matrix.python-version == 2.7 || matrix.python-version == 3.6 }}
65-
run: |
66-
set -xv;curl -sSL https://bootstrap.pypa.io/get-pip.py -o get-pip.py
67-
python3.8 get-pip.py
68-
# The alternative is installing python3-pip but we don't need full pip function for now:
69-
# sudo apt-get update && sudo apt-get install -y python3-pip
70-
# Let tox-gh-actions get the environment(s) to run tests with from tox.ini:
71-
# Use tox==4.5.1: tox>=4 is needed for reading the extras from pyproject.toml
72-
# Warning: tox>=4.5.2 depends on virutalenv>=20.23, which breaks Python 2.7:
73-
python3.8 -m pip install 'virtualenv<20.22' 'tox==4.5.1' tox-gh-actions
74-
tox --workdir .github/workflows/.tox --recreate
75-
7661
- name: Select the coverage file for upload
7762
if: |
7863
( matrix.python-version == '3.6' || matrix.python-version == '3.11' ) &&

Diff for: .pylintrc

+4-2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ disable=W0142,W0703,C0111,R0201,W0603,W0613,W0212,W0141,
6565
len-as-condition,
6666
no-else-return,
6767
raise-missing-from,
68+
too-many-positional-arguments,
6869
too-many-branches,
6970
too-many-nested-blocks,
7071
too-many-statements,
@@ -222,8 +223,9 @@ defining-attr-methods=__init__,__new__,setUp
222223

223224
[DESIGN]
224225

225-
# Maximum number of arguments for function / method
226-
max-args=100
226+
# Maximum number of arguments for function / method.
227+
# defaults to: max-args=5
228+
max-args=10
227229

228230
# Argument names that match this expression will be ignored. Default to name
229231
# with leading underscore

Diff for: pyproject.toml

+2-7
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,6 @@ mypy = [
7171
"types-six",
7272
"types-toml",
7373
]
74-
# pyre introduced two false-postives recently, pin it to prevent further surprises:
75-
pyre = [
76-
"pyre-check == 0.9.21",
77-
"pyre-extensions == 0.0.30",
78-
]
7974
pytype = [
8075
"pandas",
8176
"pytype",
@@ -198,7 +193,7 @@ exclude = [
198193
extraPaths = ["stubs"]
199194
include = ["xcp", "tests"]
200195
pythonPlatform = "Linux"
201-
pythonVersion = "3.6"
196+
pythonVersion = "3.11"
202197
reportFunctionMemberAccess = true
203198
reportGeneralTypeIssues = "warning"
204199
reportOptionalMemberAccess = "warning"
@@ -211,7 +206,7 @@ stubPath = "stubs"
211206
inputs = ["xcp", "tests", "./*.py"]
212207
keepgoing = true
213208
platform = "linux"
214-
python_version = "3.10"
209+
python_version = "3.11"
215210
pythonpath = ".:stubs"
216211
disable = ["ignored-type-comment"]
217212
overriding_parameter_count_checks = true

Diff for: pyre_runner.py

-62
This file was deleted.

Diff for: pytest.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
required_plugins =
1212
pytest_httpserver
1313
pytest-forked
14-
pytest-localftpserver
1514
pytest-pythonpath
1615
pytest-subprocess
1716
pytest-timeout
@@ -38,4 +37,5 @@ filterwarnings=ignore:Unknown config option
3837
pythonpath=stubs
3938
# Disable when using pytest >= 7.0.0:
4039
# Used by pytest-pythonpath for Python >=2.7 (https://pypi.org/project/pytest-pythonpath):
41-
python_paths=stubs
40+
# Can now only be activated when using newer pytest:
41+
#python_paths=stubs

Diff for: stubs/pyfakefs/__init__.pyi

Whitespace-only changes.

Diff for: stubs/pyfakefs/fake_filesystem_unittest.pyi

-20
This file was deleted.

Diff for: stubs/pytest.pyi

-8
This file was deleted.

Diff for: stubs/werkzeug/wrappers.pyi

-3
This file was deleted.

Diff for: tests/conftest.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,20 @@
55
This module is run automatically by pytest to define and enable fixtures.
66
"""
77

8-
# pyre-ignore-all-errors[21]
8+
import os
9+
import tempfile
910
import warnings
1011

11-
import pytest # pyre does not find the module when run by tox -e py311-pyre
12+
import pytest
13+
14+
15+
@pytest.fixture()
16+
def mount_dir():
17+
"""pytest fixture for getting a temporary name for a temp directory"""
18+
mount_point = tempfile.mkdtemp(prefix="media-", dir="/tmp")
19+
os.rmdir(mount_point)
20+
return mount_point.encode()
21+
1222

1323
@pytest.fixture(autouse=True)
1424
def set_warnings():

Diff for: tests/httpserver_testcase.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import sys
23
import unittest
34
from typing import Callable, Optional
45

@@ -11,9 +12,10 @@
1112
from pytest_httpserver import HTTPServer
1213
from werkzeug.wrappers import Request, Response
1314

14-
ErrorHandler = Optional[Callable[[Request], Response]]
15+
ErrorHandler = Optional[Callable[[Request], Response | None]]
1516
except ImportError:
1617
pytest.skip(allow_module_level=True)
18+
sys.exit(0) # Let pyright know that this is a dead end
1719

1820

1921
class HTTPServerTestCase(unittest.TestCase):
@@ -31,7 +33,7 @@ def tearDownClass(cls):
3133

3234
@classmethod
3335
def serve_file(cls, root, file_path, error_handler=None, real_path=None):
34-
# type:(str, str, Optional[Callable[[Request], Response]], Optional[str]) -> None
36+
# type:(str, str, ErrorHandler, Optional[str]) -> None
3537
"""Expect a GET request and handle it using the local pytest_httpserver.HTTPServer"""
3638

3739
def handle_get(request):

Diff for: tests/test_accessor.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
11
import unittest
2-
3-
from pyfakefs.fake_filesystem import FakeFilesystem
2+
from typing import TYPE_CHECKING
43

54
import xcp.accessor
65

76
from .test_mountingaccessor import check_binary_read, check_binary_write
87

8+
if TYPE_CHECKING:
9+
import pyfakefs
10+
import pytest
11+
912

10-
def test_file_accessor(fs):
11-
# type:(FakeFilesystem) -> None
13+
def test_file_accessor(fs, caplog):
14+
# type(pyfakefs.fake_filesystem.FakeFilesystem, pytest.LogCaptureFixture) -> None
1215
"""Test FileAccessor.writeFile(), .openAddress and .access using pyfakefs"""
1316
accessor = xcp.accessor.createAccessor("file://repo/", False)
1417
assert isinstance(accessor, xcp.accessor.FileAccessor)
1518
check_binary_read(accessor, "/repo", fs)
16-
check_binary_write(accessor, "/repo", fs)
19+
check_binary_write(accessor, "/repo", fs, caplog)
1720

1821

1922
class TestAccessor(unittest.TestCase):
2023
def setUp(self):
21-
"""Provide the refrence content of the repo/.treeinfo file for check_repo_access()"""
24+
"""Provide the reference content of the repo/.treeinfo file for check_repo_access()"""
2225
with open("tests/data/repo/.treeinfo", "rb") as dot_treeinfo:
2326
self.reference_treeinfo = dot_treeinfo.read()
2427

Diff for: tests/test_bootloader.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ def test_grub2(self):
4141
universal_newlines=True)
4242
assert proc.stdout
4343
for line in proc.stdout:
44-
# pylint: disable-next=deprecated-method
45-
self.assertRegexpMatches(line, r"^(5a6,13$|>)")
44+
self.assertRegex(line, r"^(5a6,13$|>)") # Replaced removed assert call
4645

4746
proc.stdout.close()
4847
proc.wait()

Diff for: tests/test_ftpaccessor.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@
2121
from io import BytesIO
2222

2323
import pytest
24-
import pytest_localftpserver # pylint: disable=unused-import # Ensure that it is installed
24+
import pytest_localftpserver # Ensure that it is installed
2525
from six import ensure_binary, ensure_str
2626

2727
import xcp.accessor
2828

2929
binary_data = b"\x80\x91\xaa\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xcc\xdd\xee\xff"
3030
text_data = "✋➔Hello Accessor from the 🗺, download and verify ✅ me!"
31+
assert pytest_localftpserver
3132

3233

3334
def upload_textfile(ftpserver, accessor):

Diff for: tests/test_httpaccessor.py

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ def http_get_request_data(self, url, read_file, error_handler):
4343

4444
def assert_http_get_request_data(self, url, read_file, error_handler):
4545
# type:(str, str, ErrorHandler) -> HTTPAccessor
46-
# pyre-ignore[23]: silence false positive
4746
with self.http_get_request_data(url, read_file, error_handler) as (httpaccessor, ref):
4847
http_accessor_filehandle = httpaccessor.openAddress(read_file)
4948
if sys.version_info >= (3, 0):

Diff for: tests/test_ifrename_logic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# pyright: reportGeneralTypeIssues=false
1+
# pyright: reportGeneralTypeIssues=false,reportAttributeAccessIssue=false
22
# pytype: disable=attribute-error
33
from __future__ import print_function
44
from __future__ import unicode_literals

Diff for: tests/test_logger.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
from xcp.logger import openLog
1111

1212

13-
def test_openLog_mock_open():
13+
def test_openLog_mock_open(fs):
14+
# type(FakeFilesystem) -> None
1415
"""Cover xcp.logger.openLog.open_with_codec_handling and check the arguments used for open()"""
1516
fh = StringIO()
1617
with patch("xcp.compat.open", mock_open()) as open_mock:
@@ -31,3 +32,4 @@ def test_openLog_mock_stdin():
3132
assert openLog("test.log") is True
3233
os.close(slave_fd)
3334
os.close(master_fd)
35+
open_mock.assert_called_once_with("test.log", "a", **open_utf8)

0 commit comments

Comments
 (0)