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

CI PR #4: Fix pylint and 2nd half of the pyright warnings #146

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
2 changes: 0 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ jobs:
fail-fast: false
matrix:
include:
- python-version: '3.6'
os: ubuntu-20.04
- python-version: '3.10'
os: ubuntu-22.04
- python-version: '3.11'
Expand Down
6 changes: 4 additions & 2 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ disable=W0142,W0703,C0111,R0201,W0603,W0613,W0212,W0141,
len-as-condition,
no-else-return,
raise-missing-from,
too-many-positional-arguments,
too-many-branches,
too-many-nested-blocks,
too-many-statements,
Expand Down Expand Up @@ -222,8 +223,9 @@ defining-attr-methods=__init__,__new__,setUp

[DESIGN]

# Maximum number of arguments for function / method
max-args=100
# Maximum number of arguments for function / method.
# defaults to: max-args=5
max-args=10

# Argument names that match this expression will be ignored. Default to name
# with leading underscore
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ exclude = [
extraPaths = ["stubs"]
include = ["xcp", "tests"]
pythonPlatform = "Linux"
pythonVersion = "3.6"
pythonVersion = "3.11"
reportFunctionMemberAccess = true
reportGeneralTypeIssues = "warning"
reportOptionalMemberAccess = "warning"
Expand Down
3 changes: 2 additions & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
# These are the most of the needed pytest plugins, unfortunately this list does
# not support ;python_version<=3.0 or ;python_version>3.0. Therefore, it can
# only list plugins available for all tested python versions (2.7, 3.6 ... 3.11):
# pytest-localftpserver is also used, but its installation is not checked
# to to its installation not being detected on Ubuntu 24.04:
required_plugins =
pytest_httpserver
pytest-forked
pytest-localftpserver
pytest-pythonpath
pytest-subprocess
pytest-timeout
Expand Down
Empty file removed stubs/pyfakefs/__init__.pyi
Empty file.
151 changes: 0 additions & 151 deletions stubs/pyfakefs/fake_filesystem.pyi

This file was deleted.

20 changes: 0 additions & 20 deletions stubs/pyfakefs/fake_filesystem_unittest.pyi

This file was deleted.

8 changes: 0 additions & 8 deletions stubs/pytest.pyi

This file was deleted.

3 changes: 0 additions & 3 deletions stubs/werkzeug/wrappers.pyi

This file was deleted.

6 changes: 4 additions & 2 deletions tests/httpserver_testcase.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import sys
import unittest
from typing import Callable, Optional

Expand All @@ -11,9 +12,10 @@
from pytest_httpserver import HTTPServer
from werkzeug.wrappers import Request, Response

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


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

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

def handle_get(request):
Expand Down
11 changes: 7 additions & 4 deletions tests/test_accessor.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import unittest

from pyfakefs.fake_filesystem import FakeFilesystem
from typing import TYPE_CHECKING

import xcp.accessor

from .test_mountingaccessor import check_binary_read, check_binary_write

if TYPE_CHECKING:
import pyfakefs


def test_file_accessor(fs):
# type:(FakeFilesystem) -> None
# type(pyfakefs.fake_filesystem.FakeFilesystem) -> None
"""Test FileAccessor.writeFile(), .openAddress and .access using pyfakefs"""
accessor = xcp.accessor.createAccessor("file://repo/", False)
assert isinstance(accessor, xcp.accessor.FileAccessor)
Expand All @@ -18,7 +20,7 @@ def test_file_accessor(fs):

class TestAccessor(unittest.TestCase):
def setUp(self):
"""Provide the refrence content of the repo/.treeinfo file for check_repo_access()"""
"""Provide the reference content of the repo/.treeinfo file for check_repo_access()"""
with open("tests/data/repo/.treeinfo", "rb") as dot_treeinfo:
self.reference_treeinfo = dot_treeinfo.read()

Expand All @@ -35,6 +37,7 @@ def check_repo_access(self, a):
self.assertFalse(a.access('no_such_file'))
self.assertEqual(a.lastError, 404)
a.finish()
a.finish() # Cover the code handing a 2nd call of accessor.finish()

def test_filesystem_accessor_access(self):
"""Test FilesystemAccessor.access()"""
Expand Down
3 changes: 2 additions & 1 deletion tests/test_ftpaccessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@
from io import BytesIO

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

import xcp.accessor

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


def upload_textfile(ftpserver, accessor):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_ifrename_logic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pyright: reportGeneralTypeIssues=false
# pyright: reportGeneralTypeIssues=false,reportAttributeAccessIssue=false
# pytype: disable=attribute-error
from __future__ import print_function
from __future__ import unicode_literals
Expand Down
1 change: 1 addition & 0 deletions tests/test_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ def test_openLog_mock_stdin():
assert openLog("test.log") is True
os.close(slave_fd)
os.close(master_fd)
open_mock.assert_called_once_with("test.log", "a", **open_utf8)
1 change: 1 addition & 0 deletions tests/test_mountingaccessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import pytest

pytest.skip(allow_module_level=True)
sys.exit(0) # Let pyright know that this is a dead end

binary_data = b"\x00\x1b\x5b\x95\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xcc\xdd\xee\xff"

Expand Down
Loading
Loading