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: add ruff check build #40

Merged
merged 4 commits into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
@@ -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
20 changes: 10 additions & 10 deletions koerce/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -50,16 +50,16 @@ 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


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

Expand All @@ -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
Expand Down Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion koerce/annots.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__",)


Expand Down
12 changes: 5 additions & 7 deletions koerce/tests/test_y.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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")
Expand Down
Loading