From c7bbb64c3e973425fdcd302006a0365ea8463ee3 Mon Sep 17 00:00:00 2001 From: Elliot Ford Date: Tue, 28 Mar 2023 15:48:28 +0100 Subject: [PATCH] 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. --- rdflib/graph.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rdflib/graph.py b/rdflib/graph.py index ed8492bea..809241df4 100644 --- a/rdflib/graph.py +++ b/rdflib/graph.py @@ -675,7 +675,7 @@ def __iter__(self) -> Generator["_TripleType", None, None]: """Iterates over all triples in the store""" return self.triples((None, None, None)) - def __contains__(self, triple: _TriplePatternType) -> bool: + def __contains__(self, triple: _TripleSelectorType) -> bool: """Support for 'triple in graph' syntax""" for triple in self.triples(triple): return True @@ -1977,7 +1977,7 @@ def _spoc( c = self._graph(c) return s, p, o, c - def __contains__(self, triple_or_quad: _TripleOrQuadPatternType) -> bool: + def __contains__(self, triple_or_quad: _TripleOrQuadSelectorType) -> bool: """Support for 'triple/quad in graph' syntax""" s, p, o, c = self._spoc(triple_or_quad) for t in self.triples((s, p, o), context=c): @@ -2751,7 +2751,7 @@ def triples( for s1, p1, o1 in graph.triples((s, p, o)): yield s1, p1, o1 - def __contains__(self, triple_or_quad: _TripleOrQuadPatternType) -> bool: + def __contains__(self, triple_or_quad: _TripleOrQuadSelectorType) -> bool: context = None if len(triple_or_quad) == 4: # type error: Tuple index out of range