Skip to content

Commit fd9ecef

Browse files
CI: format check using Ruff (#1557)
* CI: format check using Ruff * precommit, setup py * gitignore ruff_cache --------- Co-authored-by: Erik Wrede <[email protected]>
1 parent 1263e9b commit fd9ecef

File tree

11 files changed

+12
-18
lines changed

11 files changed

+12
-18
lines changed

.github/workflows/lint.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ jobs:
1515
- name: Install dependencies
1616
run: |
1717
python -m pip install --upgrade pip
18-
pip install tox
18+
pip install ruff tox
19+
- name: Format check using Ruff
20+
run: ruff format --check
1921
- name: Run lint
2022
run: tox
2123
env:

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,4 @@ venv/
9090
*.sqlite3
9191
.vscode
9292
.mypy_cache
93+
.ruff_cache

.pre-commit-config.yaml

+4-3
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ repos:
2020
rev: v2.37.3
2121
hooks:
2222
- id: pyupgrade
23-
- repo: https://github.com/psf/black
24-
rev: 22.6.0
23+
- repo: https://github.com/astral-sh/ruff-pre-commit
24+
# Ruff version.
25+
rev: v0.4.10
2526
hooks:
26-
- id: black
27+
- id: ruff-format
2728
- repo: https://github.com/PyCQA/flake8
2829
rev: 5.0.4
2930
hooks:

examples/simple_example.py

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ class Patron(graphene.ObjectType):
88

99

1010
class Query(graphene.ObjectType):
11-
1211
patron = graphene.Field(Patron)
1312

1413
def resolve_patron(root, info):

examples/starwars_relay/tests/snapshots/snap_test_objectidentification.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@
2727
"data": {"node": {"id": "U2hpcDox", "name": "X-Wing"}}
2828
}
2929

30-
snapshots[
31-
"test_str_schema 1"
32-
] = '''type Query {
30+
snapshots["test_str_schema 1"] = '''type Query {
3331
rebels: Faction
3432
empire: Faction
3533
node(

graphene/relay/tests/test_node.py

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99

1010
class SharedNodeFields:
11-
1211
shared = String()
1312
something_else = String()
1413

graphene/types/enum.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ def __call__(cls, *args, **kwargs): # noqa: N805
6161
def __iter__(cls):
6262
return cls._meta.enum.__iter__()
6363

64-
def from_enum(
65-
cls, enum, name=None, description=None, deprecation_reason=None
66-
): # noqa: N805
64+
def from_enum(cls, enum, name=None, description=None, deprecation_reason=None): # noqa: N805
6765
name = name or enum.__name__
6866
description = description or enum.__doc__ or "An enumeration."
6967
meta_dict = {

graphene/types/tests/test_scalars_serialization.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def test_serializes_output_string():
3939
assert String.serialize(-1.1) == "-1.1"
4040
assert String.serialize(True) == "true"
4141
assert String.serialize(False) == "false"
42-
assert String.serialize("\U0001F601") == "\U0001F601"
42+
assert String.serialize("\U0001f601") == "\U0001f601"
4343

4444

4545
def test_serializes_output_boolean():

graphene/utils/dataloader.py

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ def __init__(
3333
cache_map=None,
3434
loop=None,
3535
):
36-
3736
self._loop = loop
3837

3938
if batch_load_fn is not None:

graphene/utils/deprecated.py

-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ def deprecated(reason):
1717
"""
1818

1919
if isinstance(reason, string_types):
20-
2120
# The @deprecated is used with a 'reason'.
2221
#
2322
# .. code-block:: python
@@ -27,7 +26,6 @@ def deprecated(reason):
2726
# pass
2827

2928
def decorator(func1):
30-
3129
if inspect.isclass(func1):
3230
fmt1 = f"Call to deprecated class {func1.__name__} ({reason})."
3331
else:
@@ -43,7 +41,6 @@ def new_func1(*args, **kwargs):
4341
return decorator
4442

4543
elif inspect.isclass(reason) or inspect.isfunction(reason):
46-
4744
# The @deprecated is used without any 'reason'.
4845
#
4946
# .. code-block:: python

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def run_tests(self):
5454
"coveralls>=4,<5",
5555
]
5656

57-
dev_requires = ["black==22.3.0", "flake8>=4,<5"] + tests_require
57+
dev_requires = ["ruff==0.4.10", "flake8>=4,<5"] + tests_require
5858

5959
setup(
6060
name="graphene",

0 commit comments

Comments
 (0)