From 627e31906b693a56825e2ca0d37451a2da0e2279 Mon Sep 17 00:00:00 2001 From: Tyler White <50381805+IndexSeek@users.noreply.github.com> Date: Sat, 5 Oct 2024 12:07:22 -0400 Subject: [PATCH 1/4] ci: add ruff check build Update pylint.yml --- .github/workflows/pylint.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/workflows/pylint.yml diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml new file mode 100644 index 0000000..17565ef --- /dev/null +++ b/.github/workflows/pylint.yml @@ -0,0 +1,21 @@ +name: Ruff Check + +on: [push, pull_request] +permissions: + contents: read +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install ruff + - name: Analysing the code with pylint + run: | + ruff check From 5416b6682390f7a6addc6dd73f5edf84480f6f8f Mon Sep 17 00:00:00 2001 From: Tyler White <50381805+IndexSeek@users.noreply.github.com> Date: Sat, 5 Oct 2024 16:21:07 +0000 Subject: [PATCH 2/4] ci: resolve ruff check F821 --- koerce/annots.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/koerce/annots.py b/koerce/annots.py index 092a787..3c3a8ca 100644 --- a/koerce/annots.py +++ b/koerce/annots.py @@ -838,7 +838,7 @@ def __call__(cls, *args, **kwargs): class Singleton(Abstract): """Cache instances of the class based on instantiation arguments.""" - __instances__: Mapping[Any, Self] = WeakValueDictionary() + __instances__: Mapping[Any, typing.Self] = WeakValueDictionary() __slots__ = ("__weakref__",) From 466091bf0a697cda1a65f302345658f09181f878 Mon Sep 17 00:00:00 2001 From: Tyler White <50381805+IndexSeek@users.noreply.github.com> Date: Sat, 5 Oct 2024 16:29:12 +0000 Subject: [PATCH 3/4] ci: resolve ruff check F405 --- koerce/__init__.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/koerce/__init__.py b/koerce/__init__.py index 59f0e93..fcc8be1 100644 --- a/koerce/__init__.py +++ b/koerce/__init__.py @@ -5,13 +5,13 @@ from ._internal import * # noqa: F403 -class _Variable(Deferred): +class _Variable(Deferred): #noqa: F405 def __init__(self, name: str): - builder = Var(name) + builder = Var(name) # noqa: F405 super().__init__(builder) def __pos__(self): - return Capture(self) + return Capture(self) # noqa: F405 def __neg__(self): return self @@ -50,8 +50,8 @@ def var(name): def namespace(module): - p = _Namespace(pattern, module) - d = _Namespace(deferred, module) + p = _Namespace(pattern, module) # noqa: F405 + d = _Namespace(deferred, module) # noqa: F405 return p, d @@ -59,7 +59,7 @@ def replace(matcher): """More convenient syntax for replacing a value with the output of a function.""" def decorator(replacer): - return Replace(matcher, replacer) + return Replace(matcher, replacer) # noqa: F405 return decorator @@ -72,8 +72,8 @@ def __init__(self): def koerce( - pat: Pattern, value: Any, context: Context = None, allow_coercion: bool = False -) -> Any: + pat: Pattern, value: Any, context: Context = None, allow_coercion: bool = False # noqa: F405 +) -> Any: # noqa: F405 """Match a value against a pattern. Parameters @@ -106,10 +106,10 @@ def koerce( ... ] """ - pat = pattern(pat, allow_coercion=allow_coercion) + pat = pattern(pat, allow_coercion=allow_coercion) # noqa: F405 try: return pat.apply(value, context) - except MatchError: + except MatchError: # noqa: F405 return NoMatch From 7ac555b09188aaafc1983afe6ef299b2a93e2044 Mon Sep 17 00:00:00 2001 From: Tyler White <50381805+IndexSeek@users.noreply.github.com> Date: Sat, 5 Oct 2024 16:29:33 +0000 Subject: [PATCH 4/4] ci: resolve ruff check E402 --- koerce/tests/test_y.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/koerce/tests/test_y.py b/koerce/tests/test_y.py index 9c0d564..20a768c 100644 --- a/koerce/tests/test_y.py +++ b/koerce/tests/test_y.py @@ -5,13 +5,6 @@ from typing import ClassVar, Generic import pytest - -pydantic = pytest.importorskip("pydantic") -msgspec = pytest.importorskip("msgspec") - -# from ibis.common.grounds import Annotable as IAnnotable -from pydantic import BaseModel, validate_call -from pydantic_core import SchemaValidator from typing_extensions import TypeVar from koerce import ( @@ -21,6 +14,11 @@ annotated, ) +msgspec = pytest.importorskip("msgspec") +pydantic = pytest.importorskip("pydantic") +from pydantic import BaseModel, validate_call # noqa: E402 +from pydantic_core import SchemaValidator # noqa: E402 + T = TypeVar("T") S = TypeVar("S") U = TypeVar("U")