Skip to content

Commit 39462d8

Browse files
authored
style: Eliminate quotes from type hints (#2578)
Since `from __future__ import annotations` is now in place where type hints are used, there is no need to use quotes in type hints. Other changes: - Clean up nitpick settings in Sphinx configuration.
1 parent 64e0244 commit 39462d8

38 files changed

+518
-576
lines changed

docs/conf.py

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -274,63 +274,17 @@ def find_version(filename):
274274

275275
nitpicky = True
276276

277-
if sphinx_version < (5,):
278-
# Being nitpicky on Sphinx 4.x causes lots of problems.
279-
logging.warning(
280-
"disabling nitpicky because sphinx is too old: %s", sphinx.__version__
281-
)
282-
nitpicky = False
283-
284277
nitpick_ignore = [
285278
("py:class", "urllib.response.addinfourl"),
286-
("py:data", "typing.Literal"),
287-
("py:class", "typing.IO[bytes]"),
288-
("py:class", "http.client.HTTPMessage"),
289279
("py:class", "importlib.metadata.EntryPoint"),
290280
("py:class", "xml.dom.minidom.Document"),
291281
("py:class", "xml.dom.minidom.DocumentFragment"),
292282
("py:class", "isodate.duration.Duration"),
293-
# sphinx-autodoc-typehints has some issues with TypeVars.
294-
# https://github.com/tox-dev/sphinx-autodoc-typehints/issues/39
295-
("py:class", "rdflib.plugin.PluginT"),
296-
# sphinx-autodoc-typehints does not like generic parmaeters in inheritance it seems
297-
("py:class", "Identifier"),
298-
# These are related to pyparsing.
299-
("py:class", "Diagnostics"),
300-
("py:class", "ParseAction"),
301-
("py:class", "ParseFailAction"),
302283
("py:class", "pyparsing.core.TokenConverter"),
303284
("py:class", "pyparsing.results.ParseResults"),
304285
("py:class", "pyparsing.core.ParserElement"),
305-
# These are related to BerkeleyDB
306-
("py:class", "db.DBEnv"),
307286
]
308287

309-
if sys.version_info < (3, 9):
310-
nitpick_ignore.extend(
311-
[
312-
("py:class", "_ContextIdentifierType"),
313-
("py:class", "_ContextType"),
314-
("py:class", "_GraphT"),
315-
("py:class", "_NamespaceSetString"),
316-
("py:class", "_ObjectType"),
317-
("py:class", "_PredicateType"),
318-
("py:class", "_QuadSelectorType"),
319-
("py:class", "_SubjectType"),
320-
("py:class", "_TripleOrPathTripleType"),
321-
("py:class", "_TripleOrQuadPathPatternType"),
322-
("py:class", "_TripleOrQuadPatternType"),
323-
("py:class", "_TriplePathPatternType"),
324-
("py:class", "_TriplePathType"),
325-
("py:class", "_TriplePatternType"),
326-
("py:class", "_TripleSelectorType"),
327-
("py:class", "_TripleType"),
328-
("py:class", "_TripleOrTriplePathType"),
329-
("py:class", "TextIO"),
330-
("py:class", "Message"),
331-
]
332-
)
333-
334288

335289
def autodoc_skip_member_handler(
336290
app: sphinx.application.Sphinx,

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ select = [
8989
"N", # pep8-naming
9090
"RUF100", # Unused noqa directive
9191
"UP010", # Unnecessary __future__ import for target Python version
92+
"UP037", # Remove quotes from type annotation
9293
"FA", # flake8-future-annotations
9394
]
9495

rdflib/compare.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ def stringify(x):
251251
self._hash_cache[color] = val
252252
return val
253253

254-
def distinguish(self, W: "Color", graph: Graph): # noqa: N803
254+
def distinguish(self, W: Color, graph: Graph): # noqa: N803
255255
colors: Dict[str, Color] = {}
256256
for n in self.nodes:
257257
new_color: Tuple[ColorItem, ...] = list(self.color) # type: ignore[assignment]
@@ -521,7 +521,7 @@ def canonical_triples(self, stats: Optional[Stats] = None):
521521

522522
def _canonicalize_bnodes(
523523
self,
524-
triple: "_TripleType",
524+
triple: _TripleType,
525525
labels: Dict[Node, str],
526526
):
527527
for term in triple:

0 commit comments

Comments
 (0)