Skip to content

Commit 07963e8

Browse files
committed
checkpoint
1 parent ea11592 commit 07963e8

File tree

11 files changed

+34
-23
lines changed

11 files changed

+34
-23
lines changed

rdflib/events.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
__doc__ = """
24
Dirt Simple Events
35
@@ -23,6 +25,12 @@
2325
<rdflib.events.Event ['data', 'foo', 'used_by']>
2426
"""
2527

28+
29+
from typing import TYPE_CHECKING, Any, Dict, Optional
30+
31+
if TYPE_CHECKING:
32+
import typing_extensions as te
33+
2634
__all__ = ["Event", "Dispatcher"]
2735

2836

@@ -53,9 +61,9 @@ class Dispatcher:
5361
subscribers.
5462
"""
5563

56-
_dispatch_map = None
64+
_dispatch_map: Optional[Dict[Any, Any]] = None
5765

58-
def set_map(self, amap):
66+
def set_map(self, amap: Dict[Any, Any]) -> te.Self:
5967
self._dispatch_map = amap
6068
return self
6169

rdflib/plugins/parsers/notation3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ def _fixslash(s: str) -> str:
276276
N3_Empty = (SYMBOL, List_NS + "Empty")
277277

278278

279-
runNamespaceValue = None
279+
runNamespaceValue: Optional[str] = None
280280

281281

282282
def runNamespace() -> str:

rdflib/plugins/sparql/parserutils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
Union,
1515
)
1616

17-
from pyparsing import ParseResults, TokenConverter, originalTextFor
17+
from pyparsing import ParseResults, ParserElement, TokenConverter, originalTextFor
1818

1919
from rdflib.term import BNode, Identifier, Variable
2020

@@ -241,7 +241,7 @@ class Comp(TokenConverter):
241241
Returns CompValue / Expr objects - depending on whether evalFn is set.
242242
"""
243243

244-
def __init__(self, name: str, expr):
244+
def __init__(self, name: str, expr: ParserElement):
245245
self.expr = expr
246246
TokenConverter.__init__(self, expr)
247247
self.setName(name)

rdflib/plugins/stores/memory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
__all__ = ["SimpleMemory", "Memory"]
3636

37-
ANY = None
37+
ANY: None = None
3838

3939

4040
class SimpleMemory(Store):

rdflib/store.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
VALID_STORE = 1
6666
CORRUPTED_STORE = 0
6767
NO_STORE = -1
68-
UNKNOWN = None
68+
UNKNOWN: None = None
6969

7070

7171
Pickler = pickle.Pickler

rdflib/tools/csv2rdf.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@
1616
import re
1717
import sys
1818
import time
19+
from typing import Any, Dict, List, Optional, Tuple
1920
import warnings
2021
from urllib.parse import quote
2122

2223
import rdflib
2324
from rdflib.namespace import RDF, RDFS, split_uri
2425

26+
from rdflib.term import URIRef
27+
2528
__all__ = ["CSV2RDF"]
2629

2730
HELP = """
@@ -87,7 +90,7 @@
8790
"""
8891

8992
# bah - ugly global
90-
uris = {}
93+
uris: Dict[Any, Tuple[URIRef, Optional[URIRef]]] = {}
9194

9295

9396
def toProperty(label):
@@ -112,7 +115,7 @@ def toPropertyLabel(label):
112115
return label
113116

114117

115-
def index(l_, i):
118+
def index(l_: List[int], i: Tuple[int, ...]) -> Tuple[int, ...]:
116119
"""return a set of indexes from a list
117120
>>> index([1,2,3],(0,2))
118121
(1, 3)
@@ -126,7 +129,7 @@ def csv_reader(csv_data, dialect=csv.excel, **kwargs):
126129
yield row
127130

128131

129-
def prefixuri(x, prefix, class_=None):
132+
def prefixuri(x, prefix, class_: Optional[URIRef] = None):
130133
if prefix:
131134
r = rdflib.URIRef(prefix + quote(x.encode("utf8").replace(" ", "_"), safe=""))
132135
else:
@@ -142,7 +145,7 @@ class NodeMaker:
142145
def range(self):
143146
return rdflib.RDFS.Literal
144147

145-
def __call__(self, x):
148+
def __call__(self, x: Any):
146149
return rdflib.Literal(x)
147150

148151

test/jsonld/test_compaction.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import itertools
44
import json
55
import re
6+
from typing import Any, Dict, List, Tuple
67

78
import pytest
89

@@ -13,11 +14,11 @@
1314
register("json-ld", Serializer, "rdflib.plugins.serializers.jsonld", "JsonLDSerializer")
1415

1516

16-
cases = []
17+
cases: List[Tuple[str, Dict[str, Any]]] = []
1718

1819

19-
def case(*args):
20-
cases.append(args)
20+
def case(source:str, data: Dict[str, Any]):
21+
cases.append((source, data))
2122

2223

2324
case(

test/test_graph/test_graph_context.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import shutil
33
import sys
4+
from typing import Optional
45
import unittest
56
from tempfile import mkdtemp, mkstemp
67

@@ -13,7 +14,7 @@
1314
class ContextTestCase(unittest.TestCase):
1415
store = "default"
1516
slow = True
16-
tmppath = None
17+
tmppath: Optional[str] = None
1718

1819
def setUp(self):
1920
try:

test/test_sparql/test_prefixed_name.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import itertools
22
import logging
33
from contextlib import ExitStack
4-
from typing import Type, Union
4+
from typing import Type, Union, Optional
55

66
import pyparsing
77
import pytest
8-
from pyparsing import Optional
98

109
import rdflib
1110
from rdflib import Graph

test/utils/sparql_checker.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -300,11 +300,11 @@ def check_syntax(monkeypatch: MonkeyPatch, entry: SPARQLEntry) -> None:
300300
if entry.type_info.negative:
301301
catcher = xstack.enter_context(pytest.raises(Exception))
302302
if entry.type_info.query_type is QueryType.UPDATE:
303-
tree = parseUpdate(query_text)
304-
translateUpdate(tree)
303+
parseTree = parseUpdate(query_text)
304+
translateUpdate(parseTree)
305305
elif entry.type_info.query_type is QueryType.QUERY:
306-
tree = parseQuery(query_text)
307-
translateQuery(tree)
306+
queryTree = parseQuery(query_text)
307+
translateQuery(queryTree)
308308
if catcher is not None:
309309
assert catcher.value is not None
310310
logging.info("catcher.value = %s", catcher.value)

0 commit comments

Comments
 (0)