mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-21 17:16:43 +03:00
CI: format check using Ruff (#1557)
* CI: format check using Ruff * precommit, setup py * gitignore ruff_cache --------- Co-authored-by: Erik Wrede <erikwrede@users.noreply.github.com>
This commit is contained in:
parent
1263e9b41e
commit
fd9ecef36e
4
.github/workflows/lint.yml
vendored
4
.github/workflows/lint.yml
vendored
|
@ -15,7 +15,9 @@ jobs:
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
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
|
- name: Run lint
|
||||||
run: tox
|
run: tox
|
||||||
env:
|
env:
|
||||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -90,3 +90,4 @@ venv/
|
||||||
*.sqlite3
|
*.sqlite3
|
||||||
.vscode
|
.vscode
|
||||||
.mypy_cache
|
.mypy_cache
|
||||||
|
.ruff_cache
|
||||||
|
|
|
@ -20,10 +20,11 @@ repos:
|
||||||
rev: v2.37.3
|
rev: v2.37.3
|
||||||
hooks:
|
hooks:
|
||||||
- id: pyupgrade
|
- id: pyupgrade
|
||||||
- repo: https://github.com/psf/black
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
rev: 22.6.0
|
# Ruff version.
|
||||||
|
rev: v0.4.10
|
||||||
hooks:
|
hooks:
|
||||||
- id: black
|
- id: ruff-format
|
||||||
- repo: https://github.com/PyCQA/flake8
|
- repo: https://github.com/PyCQA/flake8
|
||||||
rev: 5.0.4
|
rev: 5.0.4
|
||||||
hooks:
|
hooks:
|
||||||
|
|
|
@ -8,7 +8,6 @@ class Patron(graphene.ObjectType):
|
||||||
|
|
||||||
|
|
||||||
class Query(graphene.ObjectType):
|
class Query(graphene.ObjectType):
|
||||||
|
|
||||||
patron = graphene.Field(Patron)
|
patron = graphene.Field(Patron)
|
||||||
|
|
||||||
def resolve_patron(root, info):
|
def resolve_patron(root, info):
|
||||||
|
|
|
@ -27,9 +27,7 @@ snapshots["test_correctly_refetches_xwing 1"] = {
|
||||||
"data": {"node": {"id": "U2hpcDox", "name": "X-Wing"}}
|
"data": {"node": {"id": "U2hpcDox", "name": "X-Wing"}}
|
||||||
}
|
}
|
||||||
|
|
||||||
snapshots[
|
snapshots["test_str_schema 1"] = '''type Query {
|
||||||
"test_str_schema 1"
|
|
||||||
] = '''type Query {
|
|
||||||
rebels: Faction
|
rebels: Faction
|
||||||
empire: Faction
|
empire: Faction
|
||||||
node(
|
node(
|
||||||
|
|
|
@ -8,7 +8,6 @@ from ..node import Node, is_node
|
||||||
|
|
||||||
|
|
||||||
class SharedNodeFields:
|
class SharedNodeFields:
|
||||||
|
|
||||||
shared = String()
|
shared = String()
|
||||||
something_else = String()
|
something_else = String()
|
||||||
|
|
||||||
|
|
|
@ -61,9 +61,7 @@ class EnumMeta(SubclassWithMeta_Meta):
|
||||||
def __iter__(cls):
|
def __iter__(cls):
|
||||||
return cls._meta.enum.__iter__()
|
return cls._meta.enum.__iter__()
|
||||||
|
|
||||||
def from_enum(
|
def from_enum(cls, enum, name=None, description=None, deprecation_reason=None): # noqa: N805
|
||||||
cls, enum, name=None, description=None, deprecation_reason=None
|
|
||||||
): # noqa: N805
|
|
||||||
name = name or enum.__name__
|
name = name or enum.__name__
|
||||||
description = description or enum.__doc__ or "An enumeration."
|
description = description or enum.__doc__ or "An enumeration."
|
||||||
meta_dict = {
|
meta_dict = {
|
||||||
|
|
|
@ -39,7 +39,7 @@ def test_serializes_output_string():
|
||||||
assert String.serialize(-1.1) == "-1.1"
|
assert String.serialize(-1.1) == "-1.1"
|
||||||
assert String.serialize(True) == "true"
|
assert String.serialize(True) == "true"
|
||||||
assert String.serialize(False) == "false"
|
assert String.serialize(False) == "false"
|
||||||
assert String.serialize("\U0001F601") == "\U0001F601"
|
assert String.serialize("\U0001f601") == "\U0001f601"
|
||||||
|
|
||||||
|
|
||||||
def test_serializes_output_boolean():
|
def test_serializes_output_boolean():
|
||||||
|
|
|
@ -33,7 +33,6 @@ class DataLoader(object):
|
||||||
cache_map=None,
|
cache_map=None,
|
||||||
loop=None,
|
loop=None,
|
||||||
):
|
):
|
||||||
|
|
||||||
self._loop = loop
|
self._loop = loop
|
||||||
|
|
||||||
if batch_load_fn is not None:
|
if batch_load_fn is not None:
|
||||||
|
|
|
@ -17,7 +17,6 @@ def deprecated(reason):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if isinstance(reason, string_types):
|
if isinstance(reason, string_types):
|
||||||
|
|
||||||
# The @deprecated is used with a 'reason'.
|
# The @deprecated is used with a 'reason'.
|
||||||
#
|
#
|
||||||
# .. code-block:: python
|
# .. code-block:: python
|
||||||
|
@ -27,7 +26,6 @@ def deprecated(reason):
|
||||||
# pass
|
# pass
|
||||||
|
|
||||||
def decorator(func1):
|
def decorator(func1):
|
||||||
|
|
||||||
if inspect.isclass(func1):
|
if inspect.isclass(func1):
|
||||||
fmt1 = f"Call to deprecated class {func1.__name__} ({reason})."
|
fmt1 = f"Call to deprecated class {func1.__name__} ({reason})."
|
||||||
else:
|
else:
|
||||||
|
@ -43,7 +41,6 @@ def deprecated(reason):
|
||||||
return decorator
|
return decorator
|
||||||
|
|
||||||
elif inspect.isclass(reason) or inspect.isfunction(reason):
|
elif inspect.isclass(reason) or inspect.isfunction(reason):
|
||||||
|
|
||||||
# The @deprecated is used without any 'reason'.
|
# The @deprecated is used without any 'reason'.
|
||||||
#
|
#
|
||||||
# .. code-block:: python
|
# .. code-block:: python
|
||||||
|
|
Loading…
Reference in New Issue
Block a user