Skip to content

Commit aa10537

Browse files
committed
checkpoint
1 parent 49aebeb commit aa10537

File tree

9 files changed

+29
-28
lines changed

9 files changed

+29
-28
lines changed

rdflib/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class Parser(object):
6060
def __init__(self):
6161
pass
6262

63-
def parse(self, source: "InputSource", sink: "Graph"):
63+
def parse(self, source: "InputSource", sink: "Graph") -> None:
6464
pass
6565

6666

rdflib/paths.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,8 @@ def __repr__(self) -> str:
255255
return "Path(~%s)" % (self.arg,)
256256

257257
def n3(self, namespace_manager: Optional["NamespaceManager"] = None) -> str:
258-
return "^%s" % self.arg.n3(namespace_manager)
258+
# type error: Item "Path" of "Union[Path, URIRef]" has no attribute "n3" [union-attr]
259+
return "^%s" % self.arg.n3(namespace_manager) # type: ignore[union-attr]
259260

260261

261262
class SequencePath(Path):
@@ -312,7 +313,8 @@ def __repr__(self) -> str:
312313
return "Path(%s)" % " / ".join(str(x) for x in self.args)
313314

314315
def n3(self, namespace_manager: Optional["NamespaceManager"] = None) -> str:
315-
return "/".join(a.n3(namespace_manager) for a in self.args)
316+
# type error: Item "Path" of "Union[Path, URIRef]" has no attribute "n3" [union-attr]
317+
return "/".join(a.n3(namespace_manager) for a in self.args) # type: ignore[union-attr]
316318

317319

318320
class AlternativePath(Path):
@@ -338,7 +340,9 @@ def __repr__(self) -> str:
338340
return "Path(%s)" % " | ".join(str(x) for x in self.args)
339341

340342
def n3(self, namespace_manager: Optional["NamespaceManager"] = None) -> str:
341-
return "|".join(a.n3(namespace_manager) for a in self.args)
343+
# type error: Item "Path" of "Union[Path, URIRef]" has no attribute "n3" [union-attr]
344+
return "|".join(a.n3(namespace_manager) for a in self.args) # type: ignore[union-attr]
345+
342346

343347
class MulPath(Path):
344348
def __init__(self, path: Union[Path, URIRef], mod: _MulPathMod):
@@ -461,7 +465,8 @@ def __repr__(self) -> str:
461465
return "Path(%s%s)" % (self.path, self.mod)
462466

463467
def n3(self, namespace_manager: Optional["NamespaceManager"] = None) -> str:
464-
return "%s%s" % (self.path.n3(namespace_manager), self.mod)
468+
# type error: Item "Path" of "Union[Path, URIRef]" has no attribute "n3" [union-attr]
469+
return "%s%s" % (self.path.n3(namespace_manager), self.mod) # type: ignore[union-attr]
465470

466471

467472
class NegatedPath(Path):
@@ -495,7 +500,8 @@ def __repr__(self) -> str:
495500
return "Path(! %s)" % ",".join(str(x) for x in self.args)
496501

497502
def n3(self, namespace_manager: Optional["NamespaceManager"] = None) -> str:
498-
return "!(%s)" % ("|".join(arg.n3(namespace_manager) for arg in self.args))
503+
# type error: Item "Path" of "Union[Path, URIRef]" has no attribute "n3" [union-attr]
504+
return "!(%s)" % ("|".join(arg.n3(namespace_manager) for arg in self.args)) # type: ignore[union-attr]
499505

500506

501507
class PathList(list):

rdflib/plugins/parsers/hext.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,8 @@ def parse(self, source: InputSource, graph: Graph, **kwargs: Any) -> None: # ty
101101
for l in fp: # noqa: E741
102102
self._parse_hextuple(cg, self._load_json_line(l))
103103
elif hasattr(source, "_InputSource__bytefile"):
104-
# type error: "InputSource" has no attribute "_InputSource__bytefile"
105-
if hasattr(source._InputSource__bytefile, "wrapped"): # type: ignore[attr-defined]
106-
# type error: "InputSource" has no attribute "_InputSource__bytefile"
104+
if hasattr(source._InputSource__bytefile, "wrapped"):
107105
for (
108106
l # noqa: E741
109-
) in (
110-
source._InputSource__bytefile.wrapped.strip().splitlines() # type: ignore[attr-defined]
111-
):
107+
) in source._InputSource__bytefile.wrapped.strip().splitlines():
112108
self._parse_hextuple(cg, self._load_json_line(l))

rdflib/plugins/parsers/notation3.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1950,8 +1950,8 @@ def normalise(
19501950
# return f.universals[n]
19511951
# f.universals[n] = f.newBlankNode()
19521952
# return f.universals[n]
1953-
1954-
return n
1953+
# type error: Incompatible return value type (got "Union[int, _AnyT]", expected "Union[URIRef, Literal, BNode, _AnyT]") [return-value]
1954+
return n # type: ignore[return-value]
19551955

19561956
def intern(self, something: _AnyT) -> _AnyT:
19571957
return something

rdflib/plugins/parsers/trig.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ def parse(self, source: InputSource, graph: Graph, encoding: str = "utf-8") -> N
139139
if encoding not in [None, "utf-8"]:
140140
raise Exception(
141141
# type error: Unsupported left operand type for % ("Tuple[str, str]")
142-
("TriG files are always utf-8 encoded, ", "I was passed: %s")
143-
% encoding # type: ignore[operator]
142+
("TriG files are always utf-8 encoded, ", "I was passed: %s") # type: ignore[operator]
143+
% encoding
144144
)
145145

146146
# we're currently being handed a Graph, not a ConjunctiveGraph

rdflib/plugins/sparql/evaluate.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,8 @@ def evalServiceQuery(ctx: QueryContext, part: CompValue):
343343
res = {}
344344
match = re.match(
345345
"^service <(.*)>[ \n]*{(.*)}[ \n]*$",
346-
part.get("service_string", ""),
346+
# type error: Argument 2 to "get" of "CompValue" has incompatible type "str"; expected "bool" [arg-type]
347+
part.get("service_string", ""), # type: ignore[arg-type]
347348
re.DOTALL | re.I,
348349
)
349350

rdflib/plugins/sparql/parser.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,9 +1530,7 @@ def expand(m):
15301530

15311531
def parseQuery(q: Union[bytes, str, IO]) -> ParseResults:
15321532
if hasattr(q, "read"):
1533-
# type error: Item "bytes" of "Union[bytes, str, IO[Any]]" has no attribute "read"
1534-
# type error: Item "str" of "Union[bytes, str, IO[Any]]" has no attribute "read"
1535-
q = q.read() # type: ignore[union-attr]
1533+
q = q.read()
15361534
if isinstance(q, bytes):
15371535
q = q.decode("utf-8")
15381536

@@ -1543,9 +1541,7 @@ def parseQuery(q: Union[bytes, str, IO]) -> ParseResults:
15431541

15441542
def parseUpdate(q: Union[bytes, str, IO]) -> CompValue:
15451543
if hasattr(q, "read"):
1546-
# type error: Item "bytes" of "Union[bytes, str, IO[Any]]" has no attribute "read"
1547-
# type error: Item "str" of "Union[bytes, str, IO[Any]]" has no attribute "read"
1548-
q = q.read() # type: ignore[union-attr]
1544+
q = q.read()
15491545

15501546
if isinstance(q, bytes):
15511547
q = q.decode("utf-8")

rdflib/plugins/sparql/parserutils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ def __init__(self, name: str, expr):
136136
Param.__init__(self, name, expr, True)
137137

138138

139+
_ValT = TypeVar("_ValT")
140+
139141

140142
class CompValue(OrderedDict):
141143

rdflib/resource.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,7 @@
289289
"""
290290

291291

292-
from typing import TYPE_CHECKING, Any, TypeVar, overload, Union
293-
294-
from pyparsing import Optional
292+
from typing import TYPE_CHECKING, Any, Optional, Union, overload
295293

296294
from rdflib.namespace import RDF
297295
from rdflib.paths import Path
@@ -355,7 +353,9 @@ def add(self, p: _PredicateType, o: _ObjectType):
355353

356354
self._graph.add((self._identifier, p, o))
357355

358-
def remove(self, p: _PredicateType, o: Optional[_ObjectType] = None):
356+
def remove(
357+
self, p: _PredicateType, o: Optional[Union[_ObjectType, Resource]] = None
358+
):
359359
if isinstance(o, Resource):
360360
o = o._identifier
361361

@@ -370,7 +370,7 @@ def set(self, p: _PredicateType, o: _ObjectType):
370370
def subjects(self, predicate=None): # rev
371371
return self._resources(self._graph.subjects(predicate, self._identifier))
372372

373-
def predicates(self, o: Optional[_ObjectType] = None):
373+
def predicates(self, o: Optional[Union[_ObjectType, Resource]] = None):
374374
if isinstance(o, Resource):
375375
o = o._identifier
376376

0 commit comments

Comments
 (0)