Skip to content

Commit 5aed51e

Browse files
committed
tests: fix typing.annotations support only ^3.9
async tutorials not supported with mypy static type checking if python version before 3.9
1 parent 1846878 commit 5aed51e

File tree

10 files changed

+63
-0
lines changed

10 files changed

+63
-0
lines changed

tests/test_async_tutorial/test_async_connect/test_async_create_connected_tables/test_async_tutorial001.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1+
import sys
2+
13
import pytest
24
from sqlalchemy import inspect
35
from sqlalchemy.ext.asyncio import create_async_engine
46

7+
beforePYTHON3_9 = sys.version_info < (3, 9)
8+
reasonPEP593 = "Annotations(PEP593 https://peps.python.org/pep-0593/) only compatible with Python ver >= 3.9"
9+
510

11+
@pytest.mark.skipif(beforePYTHON3_9, reason=reasonPEP593)
612
@pytest.mark.asyncio
713
async def test_async_tutorial001() -> None:
814
from docs_src.tutorial_async.connect_async.create_tables_async import (

tests/test_async_tutorial/test_async_connect/test_async_delete/test_async_tutorial001.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
from typing import Any, List
23
from unittest.mock import patch
34

@@ -60,6 +61,11 @@
6061
]
6162

6263

64+
beforePYTHON3_9 = sys.version_info < (3, 9)
65+
reasonPEP593 = "Annotations(PEP593 https://peps.python.org/pep-0593/) only compatible with Python ver >= 3.9"
66+
67+
68+
@pytest.mark.skipif(beforePYTHON3_9, reason=reasonPEP593)
6369
@pytest.mark.asyncio()
6470
async def test_tutorial_async(clear_sqlmodel: Any) -> None:
6571
from docs_src.tutorial_async.connect_async.delete_async import (

tests/test_async_tutorial/test_async_connect/test_async_insert/test_async_tutorial001.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
from typing import Any, List
23
from unittest.mock import patch
34

@@ -40,6 +41,11 @@
4041
]
4142

4243

44+
beforePYTHON3_9 = sys.version_info < (3, 9)
45+
reasonPEP593 = "Annotations(PEP593 https://peps.python.org/pep-0593/) only compatible with Python ver >= 3.9"
46+
47+
48+
@pytest.mark.skipif(beforePYTHON3_9, reason=reasonPEP593)
4349
@pytest.mark.asyncio()
4450
async def test_async_tutorial001(clear_sqlmodel: Any) -> None:
4551
from docs_src.tutorial_async.connect_async.insert_async import (

tests/test_async_tutorial/test_async_connect/test_async_select/test_async_tutorial001_tutorial002.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
from typing import Any, List
23
from unittest.mock import patch
34

@@ -64,6 +65,11 @@
6465
]
6566

6667

68+
beforePYTHON3_9 = sys.version_info < (3, 9)
69+
reasonPEP593 = "Annotations(PEP593 https://peps.python.org/pep-0593/) only compatible with Python ver >= 3.9"
70+
71+
72+
@pytest.mark.skipif(beforePYTHON3_9, reason=reasonPEP593)
6773
@pytest.mark.asyncio()
6874
async def test_tutorial001(clear_sqlmodel: Any) -> None:
6975
from docs_src.tutorial_async.connect_async.select_async import (
@@ -81,6 +87,7 @@ async def test_tutorial001(clear_sqlmodel: Any) -> None:
8187
assert calls == expected_calls
8288

8389

90+
@pytest.mark.skipif(beforePYTHON3_9, reason=reasonPEP593)
8491
@pytest.mark.asyncio()
8592
async def test_tutorial002(clear_sqlmodel: Any) -> None:
8693
from docs_src.tutorial_async.connect_async.select_async import (

tests/test_async_tutorial/test_async_connect/test_async_select/test_async_tutorial003.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
from typing import Any, List
23
from unittest.mock import patch
34

@@ -76,6 +77,11 @@
7677
]
7778

7879

80+
beforePYTHON3_9 = sys.version_info < (3, 9)
81+
reasonPEP593 = "Annotations(PEP593 https://peps.python.org/pep-0593/) only compatible with Python ver >= 3.9"
82+
83+
84+
@pytest.mark.skipif(beforePYTHON3_9, reason=reasonPEP593)
7985
@pytest.mark.asyncio()
8086
async def test_tutorial(clear_sqlmodel: Any) -> None:
8187
from docs_src.tutorial_async.connect_async.select_async import (

tests/test_async_tutorial/test_async_connect/test_async_select/test_async_tutorial004.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
from typing import Any, List
23
from unittest.mock import patch
34

@@ -50,6 +51,11 @@
5051
]
5152

5253

54+
beforePYTHON3_9 = sys.version_info < (3, 9)
55+
reasonPEP593 = "Annotations(PEP593 https://peps.python.org/pep-0593/) only compatible with Python ver >= 3.9"
56+
57+
58+
@pytest.mark.skipif(beforePYTHON3_9, reason=reasonPEP593)
5359
@pytest.mark.asyncio()
5460
async def test_tutorial(clear_sqlmodel: Any) -> None:
5561
from docs_src.tutorial_async.connect_async.select_async import (

tests/test_async_tutorial/test_async_connect/test_async_select/test_async_tutorial005.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
from typing import Any, List
23
from unittest.mock import patch
34

@@ -52,6 +53,11 @@
5253
]
5354

5455

56+
beforePYTHON3_9 = sys.version_info < (3, 9)
57+
reasonPEP593 = "Annotations(PEP593 https://peps.python.org/pep-0593/) only compatible with Python ver >= 3.9"
58+
59+
60+
@pytest.mark.skipif(beforePYTHON3_9, reason=reasonPEP593)
5561
@pytest.mark.asyncio()
5662
async def test_tutorial(clear_sqlmodel: Any) -> None:
5763
from docs_src.tutorial_async.connect_async.select_async import (

tests/test_async_tutorial/test_async_connect/test_async_update/test_async_tutorial001.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
from typing import Any, List
23
from unittest.mock import patch
34

@@ -50,6 +51,11 @@
5051
]
5152

5253

54+
beforePYTHON3_9 = sys.version_info < (3, 9)
55+
reasonPEP593 = "Annotations(PEP593 https://peps.python.org/pep-0593/) only compatible with Python ver >= 3.9"
56+
57+
58+
@pytest.mark.skipif(beforePYTHON3_9, reason=reasonPEP593)
5359
@pytest.mark.asyncio()
5460
async def test_tutorial(clear_sqlmodel: Any) -> None:
5561
from docs_src.tutorial_async.connect_async.update_async import (

tests/test_async_tutorial/test_async_select/test_async_tutorial001_tutorial002.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
from typing import Any, Dict, List, Union
23
from unittest.mock import patch
34

@@ -28,6 +29,11 @@ def check_calls(calls: List[List[Union[str, Dict[str, Any]]]]) -> None:
2829
}
2930

3031

32+
beforePYTHON3_9 = sys.version_info < (3, 9)
33+
reasonPEP593 = "Annotations(PEP593 https://peps.python.org/pep-0593/) only compatible with Python ver >= 3.9"
34+
35+
36+
@pytest.mark.skipif(beforePYTHON3_9, reason=reasonPEP593)
3137
@pytest.mark.asyncio
3238
async def test_tutorial_async_001(clear_sqlmodel: Any) -> None:
3339
from docs_src.tutorial_async.select_async import tutorial001_async as mod
@@ -43,6 +49,7 @@ async def test_tutorial_async_001(clear_sqlmodel: Any) -> None:
4349
check_calls(calls)
4450

4551

52+
@pytest.mark.skipif(beforePYTHON3_9, reason=reasonPEP593)
4653
@pytest.mark.asyncio
4754
async def test_tutorial_async_002(clear_sqlmodel: Any) -> None:
4855
from docs_src.tutorial_async.select_async import tutorial002_async as mod

tests/test_async_tutorial/test_async_select/test_async_tutorial003_tutorial004.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
from typing import Any, Dict, List, Union
23
from unittest.mock import patch
34

@@ -32,6 +33,11 @@ def check_calls(calls: List[List[List[Union[str, Dict[str, Any]]]]]) -> None:
3233
assert calls[0][0] == expected_result
3334

3435

36+
beforePYTHON3_9 = sys.version_info < (3, 9)
37+
reasonPEP593 = "Annotations(PEP593 https://peps.python.org/pep-0593/) only compatible with Python ver >= 3.9"
38+
39+
40+
@pytest.mark.skipif(beforePYTHON3_9, reason=reasonPEP593)
3541
@pytest.mark.asyncio
3642
async def test_tutorial_003(clear_sqlmodel: Any) -> None:
3743
from docs_src.tutorial_async.select_async import tutorial003_async as mod
@@ -48,6 +54,7 @@ async def test_tutorial_003(clear_sqlmodel: Any) -> None:
4854
check_calls(calls)
4955

5056

57+
@pytest.mark.skipif(beforePYTHON3_9, reason=reasonPEP593)
5158
@pytest.mark.asyncio
5259
async def test_tutorial_004(clear_sqlmodel: Any) -> None:
5360
from docs_src.tutorial_async.select_async import tutorial004_async as mod

0 commit comments

Comments
 (0)