Commit 47bad0e 1 parent f64b8b8 commit 47bad0e Copy full SHA for 47bad0e
File tree 6 files changed +52
-16
lines changed
6 files changed +52
-16
lines changed Original file line number Diff line number Diff line change 89
89
- name : " Type check (knowledge-store)"
90
90
run : tox -e type -c libs/knowledge-store && rm -rf libs/knowledge-store/.tox
91
91
92
+ - name : " Type check (test-utils)"
93
+ run : tox -e type -c libs/tests-utils && rm -rf libs/tests-utils/.tox
94
+
92
95
unit-tests :
93
96
name : Unit Tests (Python ${{ matrix.python-version }})
94
97
needs : ["preconditions"]
Original file line number Diff line number Diff line change @@ -16,6 +16,22 @@ testcontainers = "^3.7.1"
16
16
requests = " ^2.32.2"
17
17
pytest = " ^7.3.0"
18
18
19
-
20
19
[tool .poetry .group .dev .dependencies ]
21
- setuptools = " ^70.0.0"
20
+ mypy = " ^1.10.0"
21
+
22
+ [tool .mypy ]
23
+ disallow_any_generics = true
24
+ disallow_incomplete_defs = true
25
+ disallow_untyped_calls = true
26
+ disallow_untyped_decorators = true
27
+ disallow_untyped_defs = true
28
+ follow_imports = " normal"
29
+ ignore_missing_imports = true
30
+ no_implicit_reexport = true
31
+ show_error_codes = true
32
+ show_error_context = true
33
+ strict_equality = true
34
+ strict_optional = true
35
+ warn_redundant_casts = true
36
+ warn_return_any = true
37
+ warn_unused_ignores = true
Original file line number Diff line number Diff line change
1
+ from typing import Any
2
+
1
3
from testcontainers .core .container import DockerContainer
2
4
from testcontainers .core .waiting_utils import wait_for_logs
5
+ from typing_extensions import Self
3
6
4
7
5
8
class CassandraContainer (DockerContainer ):
6
9
def __init__ (
7
10
self ,
8
11
image : str = "docker.io/stargateio/dse-next:4.0.11-b259738f492f" ,
9
12
port : int = 9042 ,
10
- ** kwargs ,
13
+ ** kwargs : Any ,
11
14
) -> None :
12
15
super ().__init__ (image = image , ** kwargs )
13
16
self .port = port
@@ -22,13 +25,10 @@ def __init__(
22
25
self .with_env ("CASSANDRA_DC" , "datacenter1" )
23
26
self .with_exposed_ports (self .port )
24
27
25
- def _configure (self ):
26
- pass
27
-
28
- def start (self ):
29
- start_res = super ().start ()
28
+ def start (self ) -> Self :
29
+ super ().start ()
30
30
wait_for_logs (self , "Startup complete" )
31
- return start_res
31
+ return self
32
32
33
- def get_mapped_port (self ):
34
- return self .get_exposed_port (self .port )
33
+ def get_mapped_port (self ) -> int :
34
+ return int ( self .get_exposed_port (self .port ) )
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ def _get_csv_embedding(csv_file_name: str) -> Embedding:
23
23
return [[float (value ) for value in row ] for row in reader ]
24
24
25
25
@staticmethod
26
- def save_csv_embedding (csv_file_name : str , embedding : Embedding ):
26
+ def save_csv_embedding (csv_file_name : str , embedding : Embedding ) -> None :
27
27
with open (TestData ._get_test_data_path (csv_file_name ), "w" , newline = "" ) as f :
28
28
writer = csv .writer (f )
29
29
writer .writerows (embedding )
Original file line number Diff line number Diff line change 1
1
import logging
2
2
import os
3
3
from abc import ABC , abstractmethod
4
+ from typing import Optional
4
5
5
6
import cassio
6
7
from cassandra .cluster import Cluster , PlainTextAuthProvider , Session
@@ -17,7 +18,7 @@ def create_cassandra_session(self) -> Session:
17
18
18
19
19
20
class LocalCassandraTestStore (TestStore ):
20
- def __init__ (self ):
21
+ def __init__ (self ) -> None :
21
22
super ().__init__ ()
22
23
start_container = os .environ .get ("CASSANDRA_START_CONTAINER" , "true" )
23
24
self .port = 9042
@@ -45,11 +46,11 @@ def create_cassandra_session(self) -> Session:
45
46
46
47
47
48
class AstraDBTestStore (TestStore ):
48
- token : str
49
- database_id : str
49
+ token : Optional [ str ]
50
+ database_id : Optional [ str ]
50
51
env : str
51
52
52
- def __init__ (self ):
53
+ def __init__ (self ) -> None :
53
54
super ().__init__ ()
54
55
if not os .getenv ("ASTRA_DB_ID" ) or not os .getenv ("ASTRA_DB_TOKEN" ):
55
56
raise ValueError (
Original file line number Diff line number Diff line change
1
+ [tox]
2
+ min_version = 4.0
3
+ envlist = type
4
+
5
+ [testenv]
6
+ description = install dependencies
7
+ skip_install = true
8
+ allowlist_externals = poetry
9
+ commands_pre =
10
+ poetry env use system
11
+ poetry install
12
+
13
+ [testenv:type]
14
+ description = run type checking
15
+ commands =
16
+ poetry run mypy {toxinidir}
You can’t perform that action at this time.
0 commit comments