diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 9112718a5..0b3c0fc3e 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -15,7 +15,9 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install tox + pip install ruff tox + - name: Format check using Ruff + run: ruff format --check - name: Run lint run: tox env: diff --git a/.gitignore b/.gitignore index 9148845fa..fa2a6ab37 100644 --- a/.gitignore +++ b/.gitignore @@ -90,3 +90,4 @@ venv/ *.sqlite3 .vscode .mypy_cache +.ruff_cache diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index eece56e04..70c773e90 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,10 +20,11 @@ repos: rev: v2.37.3 hooks: - id: pyupgrade -- repo: https://github.com/psf/black - rev: 22.6.0 +- repo: https://github.com/astral-sh/ruff-pre-commit + # Ruff version. + rev: v0.4.10 hooks: - - id: black + - id: ruff-format - repo: https://github.com/PyCQA/flake8 rev: 5.0.4 hooks: diff --git a/examples/simple_example.py b/examples/simple_example.py index 9bee8d1f4..d2685d288 100644 --- a/examples/simple_example.py +++ b/examples/simple_example.py @@ -8,7 +8,6 @@ class Patron(graphene.ObjectType): class Query(graphene.ObjectType): - patron = graphene.Field(Patron) def resolve_patron(root, info): diff --git a/examples/starwars_relay/tests/snapshots/snap_test_objectidentification.py b/examples/starwars_relay/tests/snapshots/snap_test_objectidentification.py index ab83e3585..b06fb6bf4 100644 --- a/examples/starwars_relay/tests/snapshots/snap_test_objectidentification.py +++ b/examples/starwars_relay/tests/snapshots/snap_test_objectidentification.py @@ -27,9 +27,7 @@ "data": {"node": {"id": "U2hpcDox", "name": "X-Wing"}} } -snapshots[ - "test_str_schema 1" -] = '''type Query { +snapshots["test_str_schema 1"] = '''type Query { rebels: Faction empire: Faction node( diff --git a/graphene/relay/tests/test_node.py b/graphene/relay/tests/test_node.py index e75645664..80181a1bb 100644 --- a/graphene/relay/tests/test_node.py +++ b/graphene/relay/tests/test_node.py @@ -8,7 +8,6 @@ class SharedNodeFields: - shared = String() something_else = String() diff --git a/graphene/types/enum.py b/graphene/types/enum.py index d3469a15e..bc61cd4c6 100644 --- a/graphene/types/enum.py +++ b/graphene/types/enum.py @@ -61,9 +61,7 @@ def __call__(cls, *args, **kwargs): # noqa: N805 def __iter__(cls): return cls._meta.enum.__iter__() - def from_enum( - cls, enum, name=None, description=None, deprecation_reason=None - ): # noqa: N805 + def from_enum(cls, enum, name=None, description=None, deprecation_reason=None): # noqa: N805 name = name or enum.__name__ description = description or enum.__doc__ or "An enumeration." meta_dict = { diff --git a/graphene/types/tests/test_scalars_serialization.py b/graphene/types/tests/test_scalars_serialization.py index a0028c85d..4af8a413a 100644 --- a/graphene/types/tests/test_scalars_serialization.py +++ b/graphene/types/tests/test_scalars_serialization.py @@ -39,7 +39,7 @@ def test_serializes_output_string(): assert String.serialize(-1.1) == "-1.1" assert String.serialize(True) == "true" assert String.serialize(False) == "false" - assert String.serialize("\U0001F601") == "\U0001F601" + assert String.serialize("\U0001f601") == "\U0001f601" def test_serializes_output_boolean(): diff --git a/graphene/utils/dataloader.py b/graphene/utils/dataloader.py index 143558aa2..b8f4a0cdd 100644 --- a/graphene/utils/dataloader.py +++ b/graphene/utils/dataloader.py @@ -33,7 +33,6 @@ def __init__( cache_map=None, loop=None, ): - self._loop = loop if batch_load_fn is not None: diff --git a/graphene/utils/deprecated.py b/graphene/utils/deprecated.py index 71a5bb404..42c358fb3 100644 --- a/graphene/utils/deprecated.py +++ b/graphene/utils/deprecated.py @@ -17,7 +17,6 @@ def deprecated(reason): """ if isinstance(reason, string_types): - # The @deprecated is used with a 'reason'. # # .. code-block:: python @@ -27,7 +26,6 @@ def deprecated(reason): # pass def decorator(func1): - if inspect.isclass(func1): fmt1 = f"Call to deprecated class {func1.__name__} ({reason})." else: @@ -43,7 +41,6 @@ def new_func1(*args, **kwargs): return decorator elif inspect.isclass(reason) or inspect.isfunction(reason): - # The @deprecated is used without any 'reason'. # # .. code-block:: python diff --git a/setup.py b/setup.py index 33f611143..a0e4a55c2 100644 --- a/setup.py +++ b/setup.py @@ -54,7 +54,7 @@ def run_tests(self): "coveralls>=3.3,<4", ] -dev_requires = ["black==22.3.0", "flake8>=4,<5"] + tests_require +dev_requires = ["ruff==0.4.10", "flake8>=4,<5"] + tests_require setup( name="graphene",