Skip to content

Commit de67552

Browse files
committed
Add test to verify no typing imports are ever used
1 parent 61b2ca1 commit de67552

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from pathlib import Path
2+
3+
import pytest
4+
5+
here = Path(__file__).resolve().parent
6+
root_dir = here.parent.parent.parent
7+
8+
tests_dir = root_dir / "tests"
9+
src_dir = root_dir / "src"
10+
integration_tests_dir = tests_dir / "integration" / "tests"
11+
12+
13+
@pytest.mark.parametrize("path", [tests_dir, src_dir, integration_tests_dir])
14+
def test_no_from_typing_imports(path: Path):
15+
for python_file in path.rglob("*.py"):
16+
file_txt = python_file.read_text()
17+
if "\nfrom typing import" in file_txt:
18+
raise ValueError(
19+
f"Found `from typing import` in {python_file.relative_to(root_dir)}. Please replace the import with `typing_extensions`."
20+
)

0 commit comments

Comments
 (0)