From 305fcadb98c91c5adf720ce8e2646da6c3846b4b Mon Sep 17 00:00:00 2001 From: Hongli Chen <94642294+Honglichenn@users.noreply.github.com> Date: Wed, 13 Dec 2023 18:59:51 +0000 Subject: [PATCH] feat: Enable the linter in Windows GithubCI (#34) Signed-off-by: Hongli Chen --- .github/workflows/reuse_python_build.yml | 1 - .../adaptor_runtime/_background/frontend_runner.py | 2 +- src/openjd/adaptor_runtime/_http/request_handler.py | 10 +++++----- src/openjd/adaptor_runtime_client/connection.py | 12 ++++++------ .../unit/http/test_request_handler.py | 2 +- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/.github/workflows/reuse_python_build.yml b/.github/workflows/reuse_python_build.yml index 8e9c3d9..3c6fc5d 100644 --- a/.github/workflows/reuse_python_build.yml +++ b/.github/workflows/reuse_python_build.yml @@ -66,7 +66,6 @@ jobs: run: pip install --upgrade -r requirements-development.txt - name: Run Linting - if: ${{ matrix.os == 'ubuntu-latest'}} run: hatch run lint - name: Run Tests Linux diff --git a/src/openjd/adaptor_runtime/_background/frontend_runner.py b/src/openjd/adaptor_runtime/_background/frontend_runner.py index 554a6ad..033e4e9 100644 --- a/src/openjd/adaptor_runtime/_background/frontend_runner.py +++ b/src/openjd/adaptor_runtime/_background/frontend_runner.py @@ -367,7 +367,7 @@ def __init__(self, host, **kwargs): super(UnixHTTPConnection, self).__init__("localhost", **kwargs) def connect(self): - sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) # type: ignore[attr-defined] sock.settimeout(self.timeout) sock.connect(self.socket_path) self.sock = sock diff --git a/src/openjd/adaptor_runtime/_http/request_handler.py b/src/openjd/adaptor_runtime/_http/request_handler.py index 19ee3c3..457dc0b 100644 --- a/src/openjd/adaptor_runtime/_http/request_handler.py +++ b/src/openjd/adaptor_runtime/_http/request_handler.py @@ -114,7 +114,7 @@ def _authenticate(self) -> bool: # Verify we have a UNIX socket. if not ( isinstance(self.connection, socket.socket) - and self.connection.family == socket.AddressFamily.AF_UNIX + and self.connection.family == socket.AddressFamily.AF_UNIX # type: ignore[attr-defined] ): raise UnsupportedPlatformException( "Failed to handle request because it was not made through a UNIX socket" @@ -122,14 +122,14 @@ def _authenticate(self) -> bool: # Get the credentials of the peer process cred_buffer = self.connection.getsockopt( - socket.SOL_SOCKET, - socket.SO_PEERCRED, - socket.CMSG_SPACE(ctypes.sizeof(UCred)), + socket.SOL_SOCKET, # type: ignore[attr-defined] + socket.SO_PEERCRED, # type: ignore[attr-defined] + socket.CMSG_SPACE(ctypes.sizeof(UCred)), # type: ignore[attr-defined] ) peer_cred = UCred.from_buffer_copy(cred_buffer) # Only allow connections from a process running as the same user - return peer_cred.uid == os.getuid() + return peer_cred.uid == os.getuid() # type: ignore[attr-defined] class UCred(ctypes.Structure): diff --git a/src/openjd/adaptor_runtime_client/connection.py b/src/openjd/adaptor_runtime_client/connection.py index 5f94af3..c30d681 100644 --- a/src/openjd/adaptor_runtime_client/connection.py +++ b/src/openjd/adaptor_runtime_client/connection.py @@ -39,7 +39,7 @@ def __init__(self, host, **kwargs): super(UnixHTTPConnection, self).__init__(host, **kwargs) def connect(self): - sock = _socket.socket(_socket.AF_UNIX, _socket.SOCK_STREAM) + sock = _socket.socket(_socket.AF_UNIX, _socket.SOCK_STREAM) # type: ignore[attr-defined] sock.settimeout(self.timeout) sock.connect(self.host) self.sock = sock @@ -55,7 +55,7 @@ def _authenticate(self) -> bool: # Verify we have a UNIX socket. if not ( isinstance(self.sock, _socket.socket) - and self.sock.family == _socket.AddressFamily.AF_UNIX + and self.sock.family == _socket.AddressFamily.AF_UNIX # type: ignore[attr-defined] ): raise NotImplementedError( "Failed to handle request because it was not made through a UNIX socket" @@ -63,11 +63,11 @@ def _authenticate(self) -> bool: # Get the credentials of the peer process cred_buffer = self.sock.getsockopt( - _socket.SOL_SOCKET, - _socket.SO_PEERCRED, - _socket.CMSG_SPACE(_ctypes.sizeof(UCred)), + _socket.SOL_SOCKET, # type: ignore[attr-defined] + _socket.SO_PEERCRED, # type: ignore[attr-defined] + _socket.CMSG_SPACE(_ctypes.sizeof(UCred)), # type: ignore[attr-defined] ) peer_cred = UCred.from_buffer_copy(cred_buffer) # Only allow connections from a process running as the same user - return peer_cred.uid == _os.getuid() + return peer_cred.uid == _os.getuid() # type: ignore[attr-defined] diff --git a/test/openjd/adaptor_runtime/unit/http/test_request_handler.py b/test/openjd/adaptor_runtime/unit/http/test_request_handler.py index 725bbbe..c58771b 100644 --- a/test/openjd/adaptor_runtime/unit/http/test_request_handler.py +++ b/test/openjd/adaptor_runtime/unit/http/test_request_handler.py @@ -145,7 +145,7 @@ class TestAuthenticate: @pytest.fixture def mock_handler(self) -> MagicMock: mock_socket = MagicMock(spec=socket.socket) - mock_socket.family = socket.AddressFamily.AF_UNIX + mock_socket.family = socket.AddressFamily.AF_UNIX # type: ignore[attr-defined] mock_handler = MagicMock(spec=RequestHandler) mock_handler.connection = mock_socket