Skip to content

Commit 0251e7a

Browse files
committed
Add ruff gh action
1 parent 7d4ee06 commit 0251e7a

File tree

7 files changed

+23
-24
lines changed

7 files changed

+23
-24
lines changed

.github/workflows/run-tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818

1919
steps:
2020
- uses: actions/checkout@v2
21+
- uses: chartboost/ruff-action@v1
2122
- name: Set up Python ${{ matrix.python-version }}
2223
uses: actions/setup-python@v2
2324
with:

.pre-commit-config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.3.3
4+
hooks:
5+
- id: ruff
6+
args: ["--fix"]
7+
- id: ruff-format

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,7 @@ release:
1515
@git push --follow-tags --all
1616
@git push --tags
1717

18-
.PHONY: test tag coverage clean release
18+
install-hooks:
19+
@pre-commit install -f --install-hooks -t pre-commit
20+
21+
.PHONY: test tag coverage clean release install-hooks

ruff.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
line-length = 121
22
indent-width = 4
3+
4+
[lint]
5+
ignore = ["F401", "F403"]

yamale/schema/schema.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ def _validate_any(self, validator, data, path, strict):
172172
def _validate_subset(self, validator, data, path, strict):
173173
def _internal_validate(internal_data):
174174
sub_errors = []
175-
for val in validator.validators:
176-
err = self._validate(val, internal_data, path, strict)
175+
for v in validator.validators:
176+
err = self._validate(v, internal_data, path, strict)
177177
if not err:
178178
break
179179
sub_errors += err

yamale/util.py

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,12 @@
1-
# ABCs for containers were moved to their own module
2-
try:
3-
from collections.abc import Mapping, Set, Sequence
4-
except ImportError:
5-
from collections import Mapping, Set, Sequence
1+
from collections.abc import Mapping, Set, Sequence
62

73

8-
# Python 3 has no basestring, lets test it.
9-
try:
10-
basestring # attempt to evaluate basestring
4+
def isstr(s):
5+
return isinstance(s, str)
116

12-
def isstr(s):
13-
return isinstance(s, basestring)
147

15-
def to_unicode(s):
16-
return unicode(s)
17-
18-
except NameError:
19-
20-
def isstr(s):
21-
return isinstance(s, str)
22-
23-
def to_unicode(s):
24-
return s
8+
def to_unicode(s):
9+
return s
2510

2611

2712
def is_list(obj):

yamale/yamale_testcase.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def validate(self, validators=None):
2626
if schema is None:
2727
return
2828

29-
if type(yaml) != list:
29+
if not isinstance(yaml, list):
3030
yaml = [yaml]
3131

3232
if base_dir is not None:

0 commit comments

Comments
 (0)