diff --git a/cognite/client/_api/__init__.py b/cognite/client/_api/__init__.py index e69de29bb2..9d48db4f9f 100644 --- a/cognite/client/_api/__init__.py +++ b/cognite/client/_api/__init__.py @@ -0,0 +1 @@ +from __future__ import annotations diff --git a/cognite/client/_api/data_modeling/_data_modeling_executor.py b/cognite/client/_api/data_modeling/_data_modeling_executor.py index 6fa5c61b49..9db31d1171 100644 --- a/cognite/client/_api/data_modeling/_data_modeling_executor.py +++ b/cognite/client/_api/data_modeling/_data_modeling_executor.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from concurrent.futures import ThreadPoolExecutor from cognite.client.utils._concurrency import ConcurrencySettings, MainThreadExecutor, TaskExecutor diff --git a/cognite/client/data_classes/__init__.py b/cognite/client/data_classes/__init__.py index 516cf1b4f3..4598d30e4e 100644 --- a/cognite/client/data_classes/__init__.py +++ b/cognite/client/data_classes/__init__.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from cognite.client.data_classes.annotations import ( Annotation, AnnotationFilter, diff --git a/cognite/client/data_classes/annotation_types/__init__.py b/cognite/client/data_classes/annotation_types/__init__.py index e69de29bb2..9d48db4f9f 100644 --- a/cognite/client/data_classes/annotation_types/__init__.py +++ b/cognite/client/data_classes/annotation_types/__init__.py @@ -0,0 +1 @@ +from __future__ import annotations diff --git a/cognite/client/data_classes/data_modeling/__init__.py b/cognite/client/data_classes/data_modeling/__init__.py index 342510b3a3..a2aeeb6d58 100644 --- a/cognite/client/data_classes/data_modeling/__init__.py +++ b/cognite/client/data_classes/data_modeling/__init__.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from cognite.client.data_classes import filters from cognite.client.data_classes.data_modeling import aggregations, query from cognite.client.data_classes.data_modeling.aggregations import AggregatedValue, Aggregation diff --git a/cognite/client/utils/_auxiliary.py b/cognite/client/utils/_auxiliary.py index 2cadde6cbb..3730d3c794 100644 --- a/cognite/client/utils/_auxiliary.py +++ b/cognite/client/utils/_auxiliary.py @@ -1,9 +1,3 @@ -"""Utilities for Cognite API SDK - -This module provides helper methods and different utilities for the Cognite API Python SDK. - -This module is protected and should not be used by end-users. -""" from __future__ import annotations import functools diff --git a/cognite/client/utils/_graph.py b/cognite/client/utils/_graph.py index fcbe114cc2..8ff0e7f128 100644 --- a/cognite/client/utils/_graph.py +++ b/cognite/client/utils/_graph.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from typing import Dict, List, Set, Tuple diff --git a/tests/tests_unit/test_meta.py b/tests/tests_unit/test_meta.py index 64d090646e..b60ce6851b 100644 --- a/tests/tests_unit/test_meta.py +++ b/tests/tests_unit/test_meta.py @@ -9,3 +9,20 @@ def test_assert_no_root_init_file(): # or uses a pkgutil-style __init__.py. If any distribution does not, it will cause the namespace logic to # fail and the other sub-packages will not be importable" assert not Path("cognite/__init__.py").exists() + + +def test_ensure_all_files_use_future_annots(): + def keep(path): + skip_list = [ + "_pb2.py", # Auto-generated, dislikes changes ;) + "cognite/client/utils/_priority_tpe.py", # Module docstring at the top takes priority + ] + return all(skip not in str(path.as_posix()) for skip in skip_list) + + all_filepaths = filter(keep, Path("cognite/client/").glob("**/*.py")) + err_msg = "File: '{}' is missing 'from __future__ import annotations' at line=0" + + for filepath in all_filepaths: + with filepath.open("r") as file: + # We just read the first line from each file: + assert file.readline() == "from __future__ import annotations\n", err_msg.format(filepath)