Skip to content

Commit

Permalink
Add ruff gh action
Browse files Browse the repository at this point in the history
  • Loading branch information
cblakkan committed Mar 20, 2024
1 parent 7d4ee06 commit 0251e7a
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 24 deletions.
1 change: 1 addition & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:

steps:
- uses: actions/checkout@v2
- uses: chartboost/ruff-action@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
Expand Down
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.3
hooks:
- id: ruff
args: ["--fix"]
- id: ruff-format
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ release:
@git push --follow-tags --all
@git push --tags

.PHONY: test tag coverage clean release
install-hooks:
@pre-commit install -f --install-hooks -t pre-commit

.PHONY: test tag coverage clean release install-hooks
3 changes: 3 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
line-length = 121
indent-width = 4

[lint]
ignore = ["F401", "F403"]
4 changes: 2 additions & 2 deletions yamale/schema/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ def _validate_any(self, validator, data, path, strict):
def _validate_subset(self, validator, data, path, strict):
def _internal_validate(internal_data):
sub_errors = []
for val in validator.validators:
err = self._validate(val, internal_data, path, strict)
for v in validator.validators:
err = self._validate(v, internal_data, path, strict)
if not err:
break
sub_errors += err
Expand Down
25 changes: 5 additions & 20 deletions yamale/util.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,12 @@
# ABCs for containers were moved to their own module
try:
from collections.abc import Mapping, Set, Sequence
except ImportError:
from collections import Mapping, Set, Sequence
from collections.abc import Mapping, Set, Sequence


# Python 3 has no basestring, lets test it.
try:
basestring # attempt to evaluate basestring
def isstr(s):
return isinstance(s, str)

def isstr(s):
return isinstance(s, basestring)

def to_unicode(s):
return unicode(s)

except NameError:

def isstr(s):
return isinstance(s, str)

def to_unicode(s):
return s
def to_unicode(s):
return s


def is_list(obj):
Expand Down
2 changes: 1 addition & 1 deletion yamale/yamale_testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def validate(self, validators=None):
if schema is None:
return

if type(yaml) != list:
if not isinstance(yaml, list):
yaml = [yaml]

if base_dir is not None:
Expand Down

0 comments on commit 0251e7a

Please sign in to comment.