From 16047eb2f70d061dc7bee564a05e6ba880c7f0e2 Mon Sep 17 00:00:00 2001 From: Iwan Aucamp Date: Wed, 6 Sep 2023 01:46:20 +0200 Subject: [PATCH] style: add `from __future__ import annotations` (#2576) Add `from __future__ import annotations` to files with type hints. Using this simplifies type hints as they no longer require quoting. This is in preparation for enabling Ruff rule UP037 (quoted-annotation, Remove quotes from type annotation) [[ref](https://beta.ruff.rs/docs/rules/#pyupgrade-up)]. --- devtools/diffrtpy.py | 1 + docs/conf.py | 1 + examples/secure_with_audit.py | 1 + examples/secure_with_urlopen.py | 2 ++ pyproject.toml | 2 ++ rdflib/compare.py | 2 +- rdflib/exceptions.py | 1 + rdflib/namespace/__init__.py | 1 + rdflib/plugin.py | 3 ++- rdflib/plugins/serializers/hext.py | 2 ++ rdflib/plugins/serializers/jsonld.py | 2 ++ rdflib/plugins/serializers/nquads.py | 2 ++ rdflib/plugins/serializers/rdfxml.py | 2 ++ rdflib/plugins/serializers/trig.py | 1 + rdflib/plugins/serializers/trix.py | 2 ++ rdflib/plugins/sparql/results/rdfresults.py | 2 ++ rdflib/plugins/sparql/results/tsvresults.py | 6 +++--- rdflib/plugins/sparql/results/txtresults.py | 2 ++ rdflib/plugins/sparql/results/xmlresults.py | 2 ++ rdflib/plugins/stores/auditable.py | 1 + rdflib/plugins/stores/berkeleydb.py | 2 ++ rdflib/plugins/stores/sparqlconnector.py | 4 +++- rdflib/plugins/stores/sparqlstore.py | 2 ++ rdflib/term.py | 2 ++ rdflib/tools/chunk_serializer.py | 1 + test/conftest.py | 2 ++ test/data/fetcher.py | 2 ++ test/data/suites/trix/test_trix.py | 2 ++ test/jsonld/__init__.py | 2 ++ test/jsonld/test_context.py | 1 + test/jsonld/test_nested_arrays.py | 2 ++ test/jsonld/test_onedotone.py | 2 ++ test/jsonld/test_testsuite.py | 2 ++ .../plugins/parser/example/rdflib/plugin/parser/__init__.py | 2 ++ test/test_dataset/test_dataset_default_graph.py | 2 ++ test/test_graph/test_diff.py | 2 ++ test/test_graph/test_graph.py | 2 ++ test/test_graph/test_graph_http.py | 2 ++ test/test_graph/test_graph_redirect.py | 2 ++ test/test_graph/test_graph_store.py | 1 + test/test_graph/test_skolemization.py | 2 ++ test/test_misc/test_networking_redirect.py | 2 ++ test/test_misc/test_plugins.py | 2 ++ test/test_misc/test_security.py | 2 ++ test/test_namespace/test_definednamespace.py | 2 ++ test/test_namespace/test_namespace.py | 2 ++ test/test_parsers/test_parser_turtlelike.py | 1 + test/test_path.py | 2 ++ test/test_roundtrip.py | 2 ++ test/test_serializers/test_serializer.py | 2 ++ test/test_serializers/test_serializer_jsonld.py | 2 ++ test/test_sparql/test_forward_slash_escapes.py | 1 + test/test_sparql/test_result.py | 2 ++ test/test_sparql/test_service.py | 2 ++ test/test_sparql/test_sparql.py | 2 ++ test/test_sparql/test_sparql_parser.py | 2 ++ test/test_sparql/test_translate_algebra.py | 2 ++ test/test_store/test_namespace_binding.py | 2 ++ test/test_store/test_store_berkeleydb.py | 2 ++ test/test_store/test_store_sparqlstore.py | 2 ++ test/test_turtle_quoting.py | 1 + test/test_typing.py | 1 + test/test_util.py | 2 ++ test/test_w3c_spec/test_n3_w3c.py | 2 ++ test/test_w3c_spec/test_nquads_w3c.py | 3 +++ test/test_w3c_spec/test_nt_w3c.py | 2 ++ test/test_w3c_spec/test_rdfxml_w3c.py | 2 ++ test/test_w3c_spec/test_trig_w3c.py | 2 ++ test/test_w3c_spec/test_turtle_w3c.py | 1 + test/utils/__init__.py | 2 +- test/utils/dawg_manifest.py | 2 ++ test/utils/destination.py | 2 ++ test/utils/earl.py | 2 ++ test/utils/http.py | 2 ++ test/utils/httpservermock.py | 2 ++ test/utils/iri.py | 2 ++ test/utils/result.py | 2 ++ test/utils/test/test_iri.py | 2 ++ test/utils/test/test_outcome.py | 2 ++ test/utils/test/test_testutils.py | 2 ++ test/utils/urlopen.py | 2 ++ 81 files changed, 148 insertions(+), 7 deletions(-) diff --git a/devtools/diffrtpy.py b/devtools/diffrtpy.py index 6da8bc37b..1d4b09722 100755 --- a/devtools/diffrtpy.py +++ b/devtools/diffrtpy.py @@ -17,6 +17,7 @@ Then attach ``/var/tmp/compact.diff`` to the PR. """ +from __future__ import annotations import argparse import logging diff --git a/docs/conf.py b/docs/conf.py index 3b4e7b6e2..f6fa43b43 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -9,6 +9,7 @@ # All configuration values have a default; values that are commented out # serve to show the default. # https://www.sphinx-doc.org/en/master/usage/configuration.html +from __future__ import annotations import logging import os diff --git a/examples/secure_with_audit.py b/examples/secure_with_audit.py index f49ccd164..c8d2f5656 100644 --- a/examples/secure_with_audit.py +++ b/examples/secure_with_audit.py @@ -9,6 +9,7 @@ The code in the example then verifies that the audit hook is blocking access to URLs and files as expected. """ +from __future__ import annotations import logging import os diff --git a/examples/secure_with_urlopen.py b/examples/secure_with_urlopen.py index fd6576b1e..ad9b5d57e 100644 --- a/examples/secure_with_urlopen.py +++ b/examples/secure_with_urlopen.py @@ -1,6 +1,8 @@ """ This example demonstrates how to use a custom global URL opener installed with `urllib.request.install_opener` to block access to URLs. """ +from __future__ import annotations + import http.client import logging import os diff --git a/pyproject.toml b/pyproject.toml index 69e8a3870..f64a0cd08 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -88,6 +88,8 @@ select = [ "I", # isort "N", # pep8-naming "RUF100", # Unused noqa directive + "UP010", # Unnecessary __future__ import for target Python version + "FA", # flake8-future-annotations ] ignore = [ diff --git a/rdflib/compare.py b/rdflib/compare.py index 6384269ad..65342f857 100644 --- a/rdflib/compare.py +++ b/rdflib/compare.py @@ -72,7 +72,7 @@ _:cb558f30e21ddfc05ca53108348338ade8 "B" . """ -from __future__ import absolute_import, division, print_function +from __future__ import annotations # TODO: # - Doesn't handle quads. diff --git a/rdflib/exceptions.py b/rdflib/exceptions.py index 708756ef6..985b4b1b7 100644 --- a/rdflib/exceptions.py +++ b/rdflib/exceptions.py @@ -1,6 +1,7 @@ """ TODO: """ +from __future__ import annotations __all__ = [ "Error", diff --git a/rdflib/namespace/__init__.py b/rdflib/namespace/__init__.py index d796ec7fe..14dfdc65b 100644 --- a/rdflib/namespace/__init__.py +++ b/rdflib/namespace/__init__.py @@ -69,6 +69,7 @@ >>> RDFS.seeAlso rdflib.term.URIRef('http://www.w3.org/2000/01/rdf-schema#seeAlso') """ +from __future__ import annotations import logging import warnings diff --git a/rdflib/plugin.py b/rdflib/plugin.py index 5387f50dc..df43efac0 100644 --- a/rdflib/plugin.py +++ b/rdflib/plugin.py @@ -24,6 +24,7 @@ .. __: http://peak.telecommunity.com/DevCenter/setuptools#dynamic-discovery-of-services-and-plugins """ +from __future__ import annotations from importlib.metadata import EntryPoint, entry_points from typing import ( @@ -102,7 +103,7 @@ def getClass(self) -> Type[PluginT]: # noqa: N802 class PKGPlugin(Plugin[PluginT]): - def __init__(self, name: str, kind: Type[PluginT], ep: "EntryPoint"): + def __init__(self, name: str, kind: Type[PluginT], ep: EntryPoint): self.name = name self.kind = kind self.ep = ep diff --git a/rdflib/plugins/serializers/hext.py b/rdflib/plugins/serializers/hext.py index 9452fd0e0..eb88151b3 100644 --- a/rdflib/plugins/serializers/hext.py +++ b/rdflib/plugins/serializers/hext.py @@ -2,6 +2,8 @@ HextuplesSerializer RDF graph serializer for RDFLib. See for details about the format. """ +from __future__ import annotations + import json import warnings from typing import IO, Optional, Type, Union diff --git a/rdflib/plugins/serializers/jsonld.py b/rdflib/plugins/serializers/jsonld.py index caba86e03..fe5770744 100644 --- a/rdflib/plugins/serializers/jsonld.py +++ b/rdflib/plugins/serializers/jsonld.py @@ -34,6 +34,8 @@ # but we should consider streaming the output to deal with arbitrarily large # graphs. +from __future__ import annotations + import warnings from typing import IO, Optional diff --git a/rdflib/plugins/serializers/nquads.py b/rdflib/plugins/serializers/nquads.py index 8d7c80781..3c8d02ccc 100644 --- a/rdflib/plugins/serializers/nquads.py +++ b/rdflib/plugins/serializers/nquads.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import warnings from typing import IO, Optional diff --git a/rdflib/plugins/serializers/rdfxml.py b/rdflib/plugins/serializers/rdfxml.py index 0758b287d..ace64bc30 100644 --- a/rdflib/plugins/serializers/rdfxml.py +++ b/rdflib/plugins/serializers/rdfxml.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import xml.dom.minidom from typing import IO, Dict, Optional, Set from xml.sax.saxutils import escape, quoteattr diff --git a/rdflib/plugins/serializers/trig.py b/rdflib/plugins/serializers/trig.py index 05d673c6b..82183eca3 100644 --- a/rdflib/plugins/serializers/trig.py +++ b/rdflib/plugins/serializers/trig.py @@ -2,6 +2,7 @@ Trig RDF graph serializer for RDFLib. See for syntax specification. """ +from __future__ import annotations from typing import IO, TYPE_CHECKING, Dict, List, Optional, Tuple, Union diff --git a/rdflib/plugins/serializers/trix.py b/rdflib/plugins/serializers/trix.py index 78d4eb100..008360e6b 100644 --- a/rdflib/plugins/serializers/trix.py +++ b/rdflib/plugins/serializers/trix.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from typing import IO, Optional from rdflib.graph import ConjunctiveGraph, Graph diff --git a/rdflib/plugins/sparql/results/rdfresults.py b/rdflib/plugins/sparql/results/rdfresults.py index 903734f57..c59a40c14 100644 --- a/rdflib/plugins/sparql/results/rdfresults.py +++ b/rdflib/plugins/sparql/results/rdfresults.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from typing import IO, Any, MutableMapping, Optional, Union from rdflib.graph import Graph diff --git a/rdflib/plugins/sparql/results/tsvresults.py b/rdflib/plugins/sparql/results/tsvresults.py index b1b7aa566..94bf4c3b5 100644 --- a/rdflib/plugins/sparql/results/tsvresults.py +++ b/rdflib/plugins/sparql/results/tsvresults.py @@ -3,8 +3,9 @@ It is implemented with pyparsing, reusing the elements from the SPARQL Parser """ +from __future__ import annotations -import codecs # noqa: I001 +import codecs import typing from typing import IO, Union @@ -30,9 +31,8 @@ ) from rdflib.plugins.sparql.parserutils import Comp, CompValue, Param from rdflib.query import Result, ResultParser -from rdflib.term import BNode +from rdflib.term import BNode, URIRef from rdflib.term import Literal as RDFLiteral -from rdflib.term import URIRef ParserElement.setDefaultWhitespaceChars(" \n") diff --git a/rdflib/plugins/sparql/results/txtresults.py b/rdflib/plugins/sparql/results/txtresults.py index 3f2f1f511..999daa60c 100644 --- a/rdflib/plugins/sparql/results/txtresults.py +++ b/rdflib/plugins/sparql/results/txtresults.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from typing import IO, List, Optional, Union from rdflib.namespace import NamespaceManager diff --git a/rdflib/plugins/sparql/results/xmlresults.py b/rdflib/plugins/sparql/results/xmlresults.py index 92144196f..c1e33a8f9 100644 --- a/rdflib/plugins/sparql/results/xmlresults.py +++ b/rdflib/plugins/sparql/results/xmlresults.py @@ -7,6 +7,8 @@ Authors: Drew Perttula, Gunnar Aastrand Grimnes """ +from __future__ import annotations + import logging import xml.etree.ElementTree as xml_etree # noqa: N813 from io import BytesIO diff --git a/rdflib/plugins/stores/auditable.py b/rdflib/plugins/stores/auditable.py index 17fa0e548..78405e77e 100644 --- a/rdflib/plugins/stores/auditable.py +++ b/rdflib/plugins/stores/auditable.py @@ -14,6 +14,7 @@ system fails): A and I out of ACID. """ +from __future__ import annotations import threading from typing import TYPE_CHECKING, Any, Generator, Iterator, List, Optional, Tuple diff --git a/rdflib/plugins/stores/berkeleydb.py b/rdflib/plugins/stores/berkeleydb.py index 4f7f2229b..335ad7973 100644 --- a/rdflib/plugins/stores/berkeleydb.py +++ b/rdflib/plugins/stores/berkeleydb.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import logging from os import mkdir from os.path import abspath, exists diff --git a/rdflib/plugins/stores/sparqlconnector.py b/rdflib/plugins/stores/sparqlconnector.py index cbf7bd92a..636f2a3fb 100644 --- a/rdflib/plugins/stores/sparqlconnector.py +++ b/rdflib/plugins/stores/sparqlconnector.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import base64 import copy import logging @@ -40,7 +42,7 @@ def __init__( query_endpoint: Optional[str] = None, update_endpoint: Optional[str] = None, returnFormat: str = "xml", # noqa: N803 - method: "te.Literal['GET', 'POST', 'POST_FORM']" = "GET", + method: te.Literal["GET", "POST", "POST_FORM"] = "GET", auth: Optional[Tuple[str, str]] = None, **kwargs, ): diff --git a/rdflib/plugins/stores/sparqlstore.py b/rdflib/plugins/stores/sparqlstore.py index 89475d7de..d836b30b9 100644 --- a/rdflib/plugins/stores/sparqlstore.py +++ b/rdflib/plugins/stores/sparqlstore.py @@ -3,6 +3,8 @@ This was first done in layer-cake, and then ported to RDFLib """ +from __future__ import annotations + import collections import re from typing import ( diff --git a/rdflib/term.py b/rdflib/term.py index 445bf0f50..9ce9702ca 100644 --- a/rdflib/term.py +++ b/rdflib/term.py @@ -20,6 +20,8 @@ * Numerical Ranges """ +from __future__ import annotations + import abc import re from fractions import Fraction diff --git a/rdflib/tools/chunk_serializer.py b/rdflib/tools/chunk_serializer.py index 9f9f133a9..7d3a56b45 100644 --- a/rdflib/tools/chunk_serializer.py +++ b/rdflib/tools/chunk_serializer.py @@ -5,6 +5,7 @@ There is an option to preserve any prefixes declared for the original graph in the first file, which will be a Turtle file. """ +from __future__ import annotations from contextlib import ExitStack, contextmanager from pathlib import Path diff --git a/test/conftest.py b/test/conftest.py index 6c2119899..5bbf5041e 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import sys from contextlib import ExitStack diff --git a/test/data/fetcher.py b/test/data/fetcher.py index 1ea8e337c..c54c0bd66 100755 --- a/test/data/fetcher.py +++ b/test/data/fetcher.py @@ -1,4 +1,6 @@ #!/usr/bin/env python +from __future__ import annotations + import argparse import enum import logging diff --git a/test/data/suites/trix/test_trix.py b/test/data/suites/trix/test_trix.py index 5e553c5c8..48fcdcf7d 100644 --- a/test/data/suites/trix/test_trix.py +++ b/test/data/suites/trix/test_trix.py @@ -1,5 +1,7 @@ """This runs the TriX tests for RDFLib's informally-assembled TriX test suite.""" +from __future__ import annotations + from test.data import TEST_DATA_DIR from test.utils.manifest import RDFTest, read_manifest from test.utils.namespace import RDFT diff --git a/test/jsonld/__init__.py b/test/jsonld/__init__.py index b082da4f8..8c3c44665 100644 --- a/test/jsonld/__init__.py +++ b/test/jsonld/__init__.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from typing import List from rdflib import parser, plugin, serializer diff --git a/test/jsonld/test_context.py b/test/jsonld/test_context.py index bb5f2e7f7..87f33427d 100644 --- a/test/jsonld/test_context.py +++ b/test/jsonld/test_context.py @@ -1,6 +1,7 @@ """ JSON-LD Context Spec """ +from __future__ import annotations import json from functools import wraps diff --git a/test/jsonld/test_nested_arrays.py b/test/jsonld/test_nested_arrays.py index 43745b419..ae495cca0 100644 --- a/test/jsonld/test_nested_arrays.py +++ b/test/jsonld/test_nested_arrays.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from test.utils.namespace import EGDC from rdflib import Graph, Literal diff --git a/test/jsonld/test_onedotone.py b/test/jsonld/test_onedotone.py index 6daf6051f..7d27f4c45 100644 --- a/test/jsonld/test_onedotone.py +++ b/test/jsonld/test_onedotone.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import json import os from os import chdir, environ, getcwd diff --git a/test/jsonld/test_testsuite.py b/test/jsonld/test_testsuite.py index 5bfc87342..25da92327 100644 --- a/test/jsonld/test_testsuite.py +++ b/test/jsonld/test_testsuite.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import json from os import chdir, environ, getcwd from os import path as p diff --git a/test/plugins/parser/example/rdflib/plugin/parser/__init__.py b/test/plugins/parser/example/rdflib/plugin/parser/__init__.py index a154ed5b6..88fa65e15 100644 --- a/test/plugins/parser/example/rdflib/plugin/parser/__init__.py +++ b/test/plugins/parser/example/rdflib/plugin/parser/__init__.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from typing import TYPE_CHECKING, Set, Tuple from rdflib.namespace import Namespace diff --git a/test/test_dataset/test_dataset_default_graph.py b/test/test_dataset/test_dataset_default_graph.py index fb219770c..2d7ff427d 100644 --- a/test/test_dataset/test_dataset_default_graph.py +++ b/test/test_dataset/test_dataset_default_graph.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import itertools import logging from test.data import TEST_DATA_DIR diff --git a/test/test_graph/test_diff.py b/test/test_graph/test_diff.py index 47312a853..21bbc4e8b 100644 --- a/test/test_graph/test_diff.py +++ b/test/test_graph/test_diff.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dataclasses import dataclass, field from test.utils import ( COLLAPSED_BNODE, diff --git a/test/test_graph/test_graph.py b/test/test_graph/test_graph.py index 7ba454d29..665b4aea0 100644 --- a/test/test_graph/test_graph.py +++ b/test/test_graph/test_graph.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import logging import os from pathlib import Path diff --git a/test/test_graph/test_graph_http.py b/test/test_graph/test_graph_http.py index 1e8076a17..df1b20453 100644 --- a/test/test_graph/test_graph_http.py +++ b/test/test_graph/test_graph_http.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import logging import re from http.server import BaseHTTPRequestHandler diff --git a/test/test_graph/test_graph_redirect.py b/test/test_graph/test_graph_redirect.py index 7b8abf772..a26331cc9 100644 --- a/test/test_graph/test_graph_redirect.py +++ b/test/test_graph/test_graph_redirect.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from test.data import SIMPLE_TRIPLE_GRAPH, TEST_DATA_DIR from test.utils import GraphHelper from test.utils.http import MethodName, MockHTTPResponse diff --git a/test/test_graph/test_graph_store.py b/test/test_graph/test_graph_store.py index 5bea2bfb5..41f36cf88 100644 --- a/test/test_graph/test_graph_store.py +++ b/test/test_graph/test_graph_store.py @@ -1,6 +1,7 @@ """ Tests for usage of the Store interface from Graph/NamespaceManager. """ +from __future__ import annotations import itertools import logging diff --git a/test/test_graph/test_skolemization.py b/test/test_graph/test_skolemization.py index 5b883a035..acc77964e 100644 --- a/test/test_graph/test_skolemization.py +++ b/test/test_graph/test_skolemization.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import logging import re from test.utils import GraphHelper diff --git a/test/test_misc/test_networking_redirect.py b/test/test_misc/test_networking_redirect.py index a1c0cf98b..6c405f27a 100644 --- a/test/test_misc/test_networking_redirect.py +++ b/test/test_misc/test_networking_redirect.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from contextlib import ExitStack from copy import deepcopy from test.utils.http import headers_as_message as headers_as_message diff --git a/test/test_misc/test_plugins.py b/test/test_misc/test_plugins.py index 7263bc738..317c2618b 100644 --- a/test/test_misc/test_plugins.py +++ b/test/test_misc/test_plugins.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import importlib import logging import shutil diff --git a/test/test_misc/test_security.py b/test/test_misc/test_security.py index ea85f0a0a..bbd46e1b5 100644 --- a/test/test_misc/test_security.py +++ b/test/test_misc/test_security.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import enum import http.client import itertools diff --git a/test/test_namespace/test_definednamespace.py b/test/test_namespace/test_definednamespace.py index 3a6fdd600..d6d5272a1 100644 --- a/test/test_namespace/test_definednamespace.py +++ b/test/test_namespace/test_definednamespace.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import inspect import logging import subprocess diff --git a/test/test_namespace/test_namespace.py b/test/test_namespace/test_namespace.py index 00668127c..adf0b3fce 100644 --- a/test/test_namespace/test_namespace.py +++ b/test/test_namespace/test_namespace.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from test.utils.outcome import OutcomeChecker, OutcomePrimitive from typing import Any, Optional from warnings import warn diff --git a/test/test_parsers/test_parser_turtlelike.py b/test/test_parsers/test_parser_turtlelike.py index 723969546..114534f7c 100644 --- a/test/test_parsers/test_parser_turtlelike.py +++ b/test/test_parsers/test_parser_turtlelike.py @@ -2,6 +2,7 @@ This module contains tests for the parsing of the turtle family of formats: N3, Turtle, NTriples, NQauds and TriG. """ +from __future__ import annotations import enum import itertools diff --git a/test/test_path.py b/test/test_path.py index 970405237..1af022786 100644 --- a/test/test_path.py +++ b/test/test_path.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import logging from typing import Union diff --git a/test/test_roundtrip.py b/test/test_roundtrip.py index f601a51da..d5178955b 100644 --- a/test/test_roundtrip.py +++ b/test/test_roundtrip.py @@ -19,6 +19,8 @@ & test_serializer_hext.py) """ +from __future__ import annotations + import enum import logging import os.path diff --git a/test/test_serializers/test_serializer.py b/test/test_serializers/test_serializer.py index af22e9209..ff3979d1e 100644 --- a/test/test_serializers/test_serializer.py +++ b/test/test_serializers/test_serializer.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import enum import itertools import logging diff --git a/test/test_serializers/test_serializer_jsonld.py b/test/test_serializers/test_serializer_jsonld.py index 58c73453f..7f7118e1b 100644 --- a/test/test_serializers/test_serializer_jsonld.py +++ b/test/test_serializers/test_serializer_jsonld.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import json import logging import pprint diff --git a/test/test_sparql/test_forward_slash_escapes.py b/test/test_sparql/test_forward_slash_escapes.py index 97fc9f10e..b2d54b6b8 100644 --- a/test/test_sparql/test_forward_slash_escapes.py +++ b/test/test_sparql/test_forward_slash_escapes.py @@ -16,6 +16,7 @@ prefixed concepts, e.g. "application/json" somehow being "mime:application/json". """ +from __future__ import annotations from test.data import TEST_DATA_DIR from test.utils.graph import cached_graph diff --git a/test/test_sparql/test_result.py b/test/test_sparql/test_result.py index 8f211e337..c08fbdedf 100644 --- a/test/test_sparql/test_result.py +++ b/test/test_sparql/test_result.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import enum import inspect import itertools diff --git a/test/test_sparql/test_service.py b/test/test_sparql/test_service.py index b1e113abe..8defd2ced 100644 --- a/test/test_sparql/test_service.py +++ b/test/test_sparql/test_service.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import json from http.client import IncompleteRead, RemoteDisconnected from test.utils import helper diff --git a/test/test_sparql/test_sparql.py b/test/test_sparql/test_sparql.py index b0ad805c7..426322a42 100644 --- a/test/test_sparql/test_sparql.py +++ b/test/test_sparql/test_sparql.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import logging from test.utils import eq_ from test.utils.namespace import EGDC diff --git a/test/test_sparql/test_sparql_parser.py b/test/test_sparql/test_sparql_parser.py index a17437115..ac6ff7856 100644 --- a/test/test_sparql/test_sparql_parser.py +++ b/test/test_sparql/test_sparql_parser.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import math import sys from typing import Set, Tuple diff --git a/test/test_sparql/test_translate_algebra.py b/test/test_sparql/test_translate_algebra.py index ca9e67bdf..1fca0fa1d 100644 --- a/test/test_sparql/test_translate_algebra.py +++ b/test/test_sparql/test_translate_algebra.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import logging import os from dataclasses import dataclass, field diff --git a/test/test_store/test_namespace_binding.py b/test/test_store/test_namespace_binding.py index dfe7ff7ff..1033a6e5f 100644 --- a/test/test_store/test_namespace_binding.py +++ b/test/test_store/test_namespace_binding.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import enum import itertools import logging diff --git a/test/test_store/test_store_berkeleydb.py b/test/test_store/test_store_berkeleydb.py index a0edecc54..35a81972b 100644 --- a/test/test_store/test_store_berkeleydb.py +++ b/test/test_store/test_store_berkeleydb.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import logging import tempfile from typing import Iterable, Optional, Tuple diff --git a/test/test_store/test_store_sparqlstore.py b/test/test_store/test_store_sparqlstore.py index 781614d54..efe611765 100644 --- a/test/test_store/test_store_sparqlstore.py +++ b/test/test_store/test_store_sparqlstore.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import logging import re import socket diff --git a/test/test_turtle_quoting.py b/test/test_turtle_quoting.py index 18a65b150..d14053a1b 100644 --- a/test/test_turtle_quoting.py +++ b/test/test_turtle_quoting.py @@ -2,6 +2,7 @@ This module is intended for tests related to unquoting/unescaping in various formats that are related to turtle, such as ntriples, nquads, trig and n3. """ +from __future__ import annotations import itertools import logging diff --git a/test/test_typing.py b/test/test_typing.py index 1f414c4b5..4934b330a 100644 --- a/test/test_typing.py +++ b/test/test_typing.py @@ -17,6 +17,7 @@ # mypy: check_untyped_defs, disallow_untyped_decorators # mypy: no_implicit_optional, warn_redundant_casts, warn_unused_ignores # mypy: warn_return_any, no_implicit_reexport, strict_equality +from __future__ import annotations from typing import Set, Tuple diff --git a/test/test_util.py b/test/test_util.py index 266df9a42..7ed486f96 100644 --- a/test/test_util.py +++ b/test/test_util.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import logging import time from contextlib import ExitStack diff --git a/test/test_w3c_spec/test_n3_w3c.py b/test/test_w3c_spec/test_n3_w3c.py index 61b851a70..7573bc660 100644 --- a/test/test_w3c_spec/test_n3_w3c.py +++ b/test/test_w3c_spec/test_n3_w3c.py @@ -1,5 +1,7 @@ """This runs the nt tests for the W3C RDF Working Group's N-Quads test suite.""" +from __future__ import annotations + import itertools import os from test.data import TEST_DATA_DIR diff --git a/test/test_w3c_spec/test_nquads_w3c.py b/test/test_w3c_spec/test_nquads_w3c.py index 0c6cd3989..932202413 100644 --- a/test/test_w3c_spec/test_nquads_w3c.py +++ b/test/test_w3c_spec/test_nquads_w3c.py @@ -1,5 +1,8 @@ """This runs the nquads tests for the W3C RDF Working Group's N-Quads test suite.""" + +from __future__ import annotations + import logging from contextlib import ExitStack from test.data import TEST_DATA_DIR diff --git a/test/test_w3c_spec/test_nt_w3c.py b/test/test_w3c_spec/test_nt_w3c.py index b857f0459..9b822d795 100644 --- a/test/test_w3c_spec/test_nt_w3c.py +++ b/test/test_w3c_spec/test_nt_w3c.py @@ -1,5 +1,7 @@ """This runs the nt tests for the W3C RDF Working Group's N-Triples test suite.""" +from __future__ import annotations + import logging from contextlib import ExitStack from test.data import TEST_DATA_DIR diff --git a/test/test_w3c_spec/test_rdfxml_w3c.py b/test/test_w3c_spec/test_rdfxml_w3c.py index a3b8e5029..57f16eb22 100644 --- a/test/test_w3c_spec/test_rdfxml_w3c.py +++ b/test/test_w3c_spec/test_rdfxml_w3c.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import logging from contextlib import ExitStack from test.data import TEST_DATA_DIR diff --git a/test/test_w3c_spec/test_trig_w3c.py b/test/test_w3c_spec/test_trig_w3c.py index 9f49616fb..f482bfd37 100644 --- a/test/test_w3c_spec/test_trig_w3c.py +++ b/test/test_w3c_spec/test_trig_w3c.py @@ -1,6 +1,8 @@ """Runs the tests for the W3C RDF Working Group's TriG test suite. """ +from __future__ import annotations + import logging from contextlib import ExitStack from test.data import TEST_DATA_DIR diff --git a/test/test_w3c_spec/test_turtle_w3c.py b/test/test_w3c_spec/test_turtle_w3c.py index 5d5d06d2a..a4c70664a 100644 --- a/test/test_w3c_spec/test_turtle_w3c.py +++ b/test/test_w3c_spec/test_turtle_w3c.py @@ -1,5 +1,6 @@ """This runs the turtle tests for the W3C RDF Working Group's Turtle test suite.""" +from __future__ import annotations import logging from contextlib import ExitStack diff --git a/test/utils/__init__.py b/test/utils/__init__.py index 6726228d8..cdcedda9c 100644 --- a/test/utils/__init__.py +++ b/test/utils/__init__.py @@ -5,7 +5,7 @@ (``test/utils/tests/``). """ -from __future__ import print_function +from __future__ import annotations import enum import pprint diff --git a/test/utils/dawg_manifest.py b/test/utils/dawg_manifest.py index 06f7c6c3e..a658cba69 100644 --- a/test/utils/dawg_manifest.py +++ b/test/utils/dawg_manifest.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import logging from dataclasses import dataclass, field from test.utils import MarkListType, marks_to_list diff --git a/test/utils/destination.py b/test/utils/destination.py index ad767d1c4..c32cc34c2 100644 --- a/test/utils/destination.py +++ b/test/utils/destination.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import enum from contextlib import contextmanager from dataclasses import dataclass diff --git a/test/utils/earl.py b/test/utils/earl.py index 7628c7870..add82bc4e 100644 --- a/test/utils/earl.py +++ b/test/utils/earl.py @@ -1,6 +1,8 @@ """ PYTEST_DONT_REWRITE """ +from __future__ import annotations + import enum import logging from dataclasses import dataclass, field diff --git a/test/utils/http.py b/test/utils/http.py index e40d2a8c8..38beded0c 100644 --- a/test/utils/http.py +++ b/test/utils/http.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import collections import email.message import enum diff --git a/test/utils/httpservermock.py b/test/utils/httpservermock.py index 2f5e51de9..5bfbaa9ef 100644 --- a/test/utils/httpservermock.py +++ b/test/utils/httpservermock.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import logging from collections import defaultdict from http.server import BaseHTTPRequestHandler, HTTPServer diff --git a/test/utils/iri.py b/test/utils/iri.py index ad7419d59..58da3a8a6 100644 --- a/test/utils/iri.py +++ b/test/utils/iri.py @@ -2,6 +2,8 @@ Various utilities for working with IRIs and URIs. """ +from __future__ import annotations + import email.utils import http.client import logging diff --git a/test/utils/result.py b/test/utils/result.py index 0a634a722..0567e8717 100644 --- a/test/utils/result.py +++ b/test/utils/result.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import enum import logging import pprint diff --git a/test/utils/test/test_iri.py b/test/utils/test/test_iri.py index 43c121337..32b606e5f 100644 --- a/test/utils/test/test_iri.py +++ b/test/utils/test/test_iri.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import logging from contextlib import ExitStack from pathlib import PurePath, PurePosixPath, PureWindowsPath diff --git a/test/utils/test/test_outcome.py b/test/utils/test/test_outcome.py index 56a730052..6276d0cee 100644 --- a/test/utils/test/test_outcome.py +++ b/test/utils/test/test_outcome.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from contextlib import ExitStack from test.utils.outcome import ExceptionChecker, OutcomeChecker from typing import Any, Callable, NoReturn, Optional, Type, Union diff --git a/test/utils/test/test_testutils.py b/test/utils/test/test_testutils.py index 44a0292ec..c9b10592b 100644 --- a/test/utils/test/test_testutils.py +++ b/test/utils/test/test_testutils.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os from contextlib import ExitStack from dataclasses import dataclass diff --git a/test/utils/urlopen.py b/test/utils/urlopen.py index fb6597077..9cfe76a88 100644 --- a/test/utils/urlopen.py +++ b/test/utils/urlopen.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import urllib.request from contextlib import contextmanager from typing import Generator, Optional