Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fa8f9b5

Browse files
committed
Minor changes as suggested by ruff
1 parent 76975cf commit fa8f9b5

File tree

14 files changed

+47
-26
lines changed

14 files changed

+47
-26
lines changed

‎pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ ignore = [
165165
"D401", # do not always require imperative mood in first line
166166
"FBT001", "FBT002", "FBT003", # allow boolean parameters
167167
"ISC001", # allow string literal concatenation for auto-formatting
168+
"PLC0415", # allow run-time imports to avoid circular dependencies
168169
"PGH003", # type ignores do not need to be specific
169170
"PLR2004", # allow some "magic" values
170171
"PYI034", # do not check return value of new method

‎src/graphql/execution/incremental_publisher.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class FormattedPendingResult(TypedDict, total=False):
6464
label: str
6565

6666

67-
class PendingResult:
67+
class PendingResult:# noqa: PLW1641
6868
"""Pending execution result"""
6969

7070
id: str
@@ -127,7 +127,7 @@ class FormattedCompletedResult(TypedDict, total=False):
127127
errors: list[GraphQLFormattedError]
128128

129129

130-
class CompletedResult:
130+
class CompletedResult:# noqa: PLW1641
131131
"""Completed execution result"""
132132

133133
id: str
@@ -192,7 +192,7 @@ class FormattedExecutionResult(TypedDict, total=False):
192192
extensions: dict[str, Any]
193193

194194

195-
class ExecutionResult:
195+
class ExecutionResult:# noqa: PLW1641
196196
"""The result of GraphQL execution.
197197
198198
- ``data`` is the result of a successful execution of the query.
@@ -267,7 +267,7 @@ class FormattedInitialIncrementalExecutionResult(TypedDict, total=False):
267267
extensions: dict[str, Any]
268268

269269

270-
class InitialIncrementalExecutionResult:
270+
class InitialIncrementalExecutionResult:# noqa: PLW1641
271271
"""Initial incremental execution result."""
272272

273273
data: dict[str, Any] | None
@@ -369,7 +369,7 @@ class FormattedIncrementalDeferResult(TypedDict, total=False):
369369
extensions: dict[str, Any]
370370

371371

372-
class IncrementalDeferResult:
372+
class IncrementalDeferResult:# noqa: PLW1641
373373
"""Incremental deferred execution result"""
374374

375375
data: dict[str, Any]
@@ -461,7 +461,7 @@ class FormattedIncrementalStreamResult(TypedDict, total=False):
461461
extensions: dict[str, Any]
462462

463463

464-
class IncrementalStreamResult:
464+
class IncrementalStreamResult:# noqa: PLW1641
465465
"""Incremental streamed execution result"""
466466

467467
items: list[Any]
@@ -560,7 +560,7 @@ class FormattedSubsequentIncrementalExecutionResult(TypedDict, total=False):
560560
extensions: dict[str, Any]
561561

562562

563-
class SubsequentIncrementalExecutionResult:
563+
class SubsequentIncrementalExecutionResult:# noqa: PLW1641
564564
"""Subsequent incremental execution result."""
565565

566566
__slots__ = "completed", "extensions", "has_next", "incremental", "pending"

‎src/graphql/language/location.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ def __eq__(self, other: object) -> bool:
4141
def __ne__(self, other: object) -> bool:
4242
return not self == other
4343

44+
def __hash__(self) -> int:
45+
return hash((self.line, self.column))
46+
4447

4548
def get_location(source: Source, position: int) -> SourceLocation:
4649
"""Get the line and column for a character position in the source.

‎src/graphql/language/source.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ def __eq__(self, other: object) -> bool:
7272
def __ne__(self, other: object) -> bool:
7373
return not self == other
7474

75+
def __hash__(self) -> int:
76+
return hash(self.body)
77+
7578

7679
def is_source(source: Any) -> TypeGuard[Source]:
7780
"""Test if the given value is a Source object.

‎src/graphql/pyutils/inspect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def trunc_list(s: list) -> list:
171171
if len(s) > max_list_size:
172172
i = max_list_size // 2
173173
j = i - 1
174-
s = s[:i]+ [ELLIPSIS] +s[-j:]
174+
s = [*s[:i], ELLIPSIS, *s[-j:]]
175175
return s
176176

177177

‎src/graphql/type/definition.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ class GraphQLFieldKwargs(TypedDict, total=False):
479479
ast_node: FieldDefinitionNode | None
480480

481481

482-
class GraphQLField:
482+
class GraphQLField:# noqa: PLW1641
483483
"""Definition of a GraphQL field"""
484484

485485
type: GraphQLOutputType
@@ -644,7 +644,7 @@ class GraphQLArgumentKwargs(TypedDict, total=False):
644644
ast_node: InputValueDefinitionNode | None
645645

646646

647-
class GraphQLArgument:
647+
class GraphQLArgument:# noqa: PLW1641
648648
"""Definition of a GraphQL argument"""
649649

650650
type: GraphQLInputType
@@ -1219,7 +1219,7 @@ class GraphQLEnumValueKwargs(TypedDict, total=False):
12191219
ast_node: EnumValueDefinitionNode | None
12201220

12211221

1222-
class GraphQLEnumValue:
1222+
class GraphQLEnumValue:# noqa: PLW1641
12231223
"""A GraphQL enum value."""
12241224

12251225
value: Any
@@ -1394,7 +1394,7 @@ class GraphQLInputFieldKwargs(TypedDict, total=False):
13941394
ast_node: InputValueDefinitionNode | None
13951395

13961396

1397-
class GraphQLInputField:
1397+
class GraphQLInputField:# noqa: PLW1641
13981398
"""Definition of a GraphQL input field"""
13991399

14001400
type: GraphQLInputType

‎src/graphql/type/directives.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class GraphQLDirectiveKwargs(TypedDict, total=False):
4949
ast_node: ast.DirectiveDefinitionNode | None
5050

5151

52-
class GraphQLDirective:
52+
class GraphQLDirective:# noqa: PLW1641
5353
"""GraphQL Directive
5454
5555
Directives are used by the GraphQL runtime as a way of modifying execution behavior.

‎src/graphql/utilities/ast_to_dict.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def ast_to_dict(
4848
res.update(
4949
{
5050
key: ast_to_dict(getattr(node, key), locations, cache)
51-
for key in ("kind",) +node.keys[1:]
51+
for key in ("kind",*node.keys[1:])
5252
}
5353
)
5454
if locations:

‎tests/execution/test_defer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ def can_compare_pending_result():
214214
assert result == tuple(args.values())
215215
assert result == tuple(args.values())[:2]
216216
assert result != tuple(args.values())[:1]
217-
assert result != tuple(args.values())[:1]+ (["bar", 2],)
217+
assert result != (*tuple(args.values())[:1], ["bar", 2])
218218
assert result == args
219219
assert result != {**args, "id": "bar"}
220220
assert result != {**args, "path": ["bar", 2]}
@@ -239,7 +239,7 @@ def can_compare_completed_result():
239239
)
240240
assert result == tuple(args.values())
241241
assert result != tuple(args.values())[:1]
242-
assert result != tuple(args.values())[:1]+ ([GraphQLError("oops")],)
242+
assert result != (*tuple(args.values())[:1], [GraphQLError("oops")])
243243
assert result == args
244244
assert result != {**args, "id": "bar"}
245245
assert result != {**args, "errors": [{"message": "oops"}]}

‎tests/language/test_location.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,10 @@ def can_compare_with_formatted_location():
4141
different_location = SourceLocation(2, 2).formatted
4242
assert not location == different_location # noqa: SIM201
4343
assert location != different_location
44+
45+
def can_be_hashed():
46+
location = SourceLocation(1, 2)
47+
same_location = SourceLocation(1, 2)
48+
assert hash(location) == hash(same_location)
49+
different_location = SourceLocation(2, 2)
50+
assert hash(location) != hash(different_location)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /