Skip to content

Use ruff format to replace black #1473

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ default_language_version:
python: python3.11
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-merge-conflict
- id: check-json
Expand All @@ -15,12 +15,9 @@ repos:
- --autofix
- id: trailing-whitespace
exclude: README.md
- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.283
rev: v0.1.2
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix, --show-fixes]
- id: ruff-format
2 changes: 1 addition & 1 deletion .ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ ignore = [
"B017", # pytest.raises(Exception) should be considered evil
"B028", # warnings.warn called without an explicit stacklevel keyword argument
"B904", # check for raise statements in exception handlers that lack a from clause
"W191", # https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
]

exclude = [
Expand All @@ -29,5 +30,4 @@ target-version = "py38"
[isort]
known-first-party = ["graphene", "graphene-django"]
known-local-folder = ["cookbook"]
force-wrap-aliases = true
combine-as-imports = true
2 changes: 1 addition & 1 deletion graphene_django/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def connection_resolver(
enforce_first_or_last,
root,
info,
**args
**args,
):
first = args.get("first")
last = args.get("last")
Expand Down
2 changes: 1 addition & 1 deletion graphene_django/filter/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __init__(
extra_filter_meta=None,
filterset_class=None,
*args,
**kwargs
**kwargs,
):
self._fields = fields
self._provided_filterset_class = filterset_class
Expand Down
4 changes: 2 additions & 2 deletions graphene_django/filter/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def replace_csv_filters(filterset_class):
label=filter_field.label,
method=filter_field.method,
exclude=filter_field.exclude,
**filter_field.extra
**filter_field.extra,
)
elif filter_type == "range":
filterset_class.base_filters[name] = RangeFilter(
Expand All @@ -154,5 +154,5 @@ def replace_csv_filters(filterset_class):
label=filter_field.label,
method=filter_field.method,
exclude=filter_field.exclude,
**filter_field.extra
**filter_field.extra,
)
3 changes: 1 addition & 2 deletions graphene_django/forms/mutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ def fields_for_form(form, only_fields, exclude_fields):
for name, field in form.fields.items():
is_not_in_only = only_fields and name not in only_fields
is_excluded = (
name
in exclude_fields # or
name in exclude_fields # or
# name in already_created_fields
)

Expand Down
2 changes: 1 addition & 1 deletion graphene_django/rest_framework/mutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def __init_subclass_with_meta__(
convert_choices_to_enum=True,
_meta=None,
optional_fields=(),
**options
**options,
):
if not serializer_class:
raise Exception("serializer_class is required for the SerializerMutation")
Expand Down
2 changes: 1 addition & 1 deletion graphene_django/rest_framework/tests/test_mutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ class Meta:
result = MyMethodMutation.mutate_and_get_payload(
None,
mock_info(),
**{"cool_name": "Narf", "last_edited": datetime.date(2020, 1, 4)}
**{"cool_name": "Narf", "last_edited": datetime.date(2020, 1, 4)},
)

assert result.errors is None
Expand Down
6 changes: 2 additions & 4 deletions graphene_django/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,8 @@ def validate_fields(type_, model, fields, only_fields, exclude_fields):
if name in all_field_names:
# Field is a custom field
warnings.warn(
(
'Excluding the custom field "{field_name}" on DjangoObjectType "{type_}" has no effect. '
'Either remove the custom field or remove the field from the "exclude" list.'
).format(field_name=name, type_=type_)
f'Excluding the custom field "{name}" on DjangoObjectType "{type_}" has no effect. '
'Either remove the custom field or remove the field from the "exclude" list.'
)
else:
if not hasattr(model, name):
Expand Down
2 changes: 1 addition & 1 deletion graphene_django/utils/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def graphql_query(
graphql_url,
json.dumps(body),
content_type="application/json",
**header_params
**header_params,
)
else:
resp = client.post(
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@


dev_requires = [
"black==23.7.0",
"ruff==0.0.283",
"ruff==0.1.2",
"pre-commit",
] + tests_require

Expand Down