Skip to content

Commit c7bbb64

Browse files
committed
widen Graph.__contains___ triple type hint
Paths are valid as the second argument of the triple here, as ultimately the triples method is called, which accepts either a predicate or a Path.
1 parent 40be70e commit c7bbb64

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

rdflib/graph.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ def __iter__(self) -> Generator["_TripleType", None, None]:
675675
"""Iterates over all triples in the store"""
676676
return self.triples((None, None, None))
677677

678-
def __contains__(self, triple: _TriplePatternType) -> bool:
678+
def __contains__(self, triple: _TripleSelectorType) -> bool:
679679
"""Support for 'triple in graph' syntax"""
680680
for triple in self.triples(triple):
681681
return True
@@ -1977,7 +1977,7 @@ def _spoc(
19771977
c = self._graph(c)
19781978
return s, p, o, c
19791979

1980-
def __contains__(self, triple_or_quad: _TripleOrQuadPatternType) -> bool:
1980+
def __contains__(self, triple_or_quad: _TripleOrQuadSelectorType) -> bool:
19811981
"""Support for 'triple/quad in graph' syntax"""
19821982
s, p, o, c = self._spoc(triple_or_quad)
19831983
for t in self.triples((s, p, o), context=c):
@@ -2751,7 +2751,7 @@ def triples(
27512751
for s1, p1, o1 in graph.triples((s, p, o)):
27522752
yield s1, p1, o1
27532753

2754-
def __contains__(self, triple_or_quad: _TripleOrQuadPatternType) -> bool:
2754+
def __contains__(self, triple_or_quad: _TripleOrQuadSelectorType) -> bool:
27552755
context = None
27562756
if len(triple_or_quad) == 4:
27572757
# type error: Tuple index out of range

0 commit comments

Comments
 (0)