From 3e2dff02bc08a840c74c0910e0303c92c8a7c306 Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Wed, 10 Jul 2024 09:23:39 +0200 Subject: [PATCH] Add ruff formatting and linting (#65) --- .github/workflows/ci.yml | 14 ++++++++++++++ clr_loader/__init__.py | 2 +- clr_loader/mono.py | 3 ++- clr_loader/util/find.py | 3 ++- doc/conf.py | 7 ++++--- tests/test_common.py | 1 - 6 files changed, 23 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 41f4e0c..3495443 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,6 +27,20 @@ jobs: path: "dist/*" if-no-files-found: error + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depths: 0 + - uses: actions/setup-python@v4 + - name: Install Ruff + run: pip install ruff + - name: Check format + run: ruff format --check + - name: Check lints + run: ruff check + test: runs-on: ${{ matrix.os }} needs: build diff --git a/clr_loader/__init__.py b/clr_loader/__init__.py index aa604ad..71eb09d 100644 --- a/clr_loader/__init__.py +++ b/clr_loader/__init__.py @@ -32,7 +32,7 @@ def get_mono( jit_options: Optional[Sequence[str]] = None, assembly_dir: Optional[str] = None, config_dir: Optional[str] = None, - set_signal_chaining: bool = False + set_signal_chaining: bool = False, ) -> Runtime: """Get a Mono runtime instance diff --git a/clr_loader/mono.py b/clr_loader/mono.py index 7c3f20d..1899ea3 100644 --- a/clr_loader/mono.py +++ b/clr_loader/mono.py @@ -86,7 +86,8 @@ class MethodDesc: def __init__(self, typename, function): self._desc = f"{typename}:{function}" self._ptr = _MONO.mono_method_desc_new( - self._desc.encode("utf8"), 1 # include_namespace + self._desc.encode("utf8"), + 1, # include_namespace ) def search(self, image): diff --git a/clr_loader/util/find.py b/clr_loader/util/find.py index 6ef7bc3..65bc7ac 100644 --- a/clr_loader/util/find.py +++ b/clr_loader/util/find.py @@ -137,8 +137,9 @@ def find_libmono(*, assembly_dir: str = None, sgen: bool = True) -> Path: ) else: - if assembly_dir == None: + if assembly_dir is None: from ctypes.util import find_library + path = find_library(unix_name) else: libname = "lib" + unix_name + ".so" diff --git a/doc/conf.py b/doc/conf.py index 1ad2427..385629c 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -1,3 +1,6 @@ +import sys +from pathlib import Path + project = "clr-loader" copyright = "2022, Benedikt Reinartz" author = "Benedikt Reinartz" @@ -5,9 +8,7 @@ extensions = ["sphinx.ext.autodoc"] # Add parent to path for autodoc -import sys, os - -sys.path.append(os.path.abspath("..")) +sys.path.append(str(Path("..").absolute())) # autodoc_typehints = "both" diff --git a/tests/test_common.py b/tests/test_common.py index 8a9e36d..139f192 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -1,7 +1,6 @@ import shutil import pytest from subprocess import check_call -import os import sys from pathlib import Path