Skip to content

Commit 4eca7b7

Browse files
committed
OverlappingFieldsCanBeMergedRule: futher simplify PairSet
Replicates graphql/graphql-js@b39b47d
1 parent 95ee2f0 commit 4eca7b7

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/graphql/validation/rules/overlapping_fields_can_be_merged.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -726,8 +726,7 @@ def subfield_conflicts(
726726
class PairSet:
727727
"""Pair set
728728
729-
A way to keep track of pairs of things when the ordering of the pair does not
730-
matter. We do this by maintaining a sort of double adjacency sets.
729+
A way to keep track of pairs of things when the ordering of the pair doesn't matter.
731730
"""
732731

733732
__slots__ = ("_data",)
@@ -746,12 +745,11 @@ def has(self, a: str, b: str, are_mutually_exclusive: bool) -> bool:
746745
result = map_.get(key2)
747746
if result is None:
748747
return False
749-
# `are_mutually_exclusive` being False is a superset of being True, hence if we
750-
# want to know if this PairSet "has" these two with no exclusivity, we have to
751-
# ensure it was added as such.
752-
if not are_mutually_exclusive:
753-
return not result
754-
return True
748+
749+
# are_mutually_exclusive being False is a superset of being True,
750+
# hence if we want to know if this PairSet "has" these two with no exclusivity,
751+
# we have to ensure it was added as such.
752+
return True if are_mutually_exclusive else are_mutually_exclusive == result
755753

756754
def add(self, a: str, b: str, are_mutually_exclusive: bool) -> None:
757755
key1, key2 = (a, b) if a < b else (b, a)

0 commit comments

Comments
 (0)