Skip to content

Commit d0e8cd8

Browse files
authored
Upgrading mypy (#4062)
* adding new version, removing old version * use 3.10 for migration tests * ignore tensorflow for dev environments in 3.13 too * remove 0.40.3 from the migration tests * remove importlib_metadata properly * formatting * updated pytest-split for 3.13 * some integration changes * tensorboard changes * more tensorboard * ignoring deepchecks tests on 3.13 * skip windows 3.13 due to numpy failures * ignore 3.13 windows as well * mypy changes * middlewares * ignore * fixing ignores * ignores * name change
1 parent 9f92783 commit d0e8cd8

File tree

14 files changed

+28
-22
lines changed

14 files changed

+28
-22
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ dev = [
121121
"yamlfix>=1.16.0",
122122
"coverage[toml]>=5.5,<6.0.0",
123123
"pytest>=7.4.0,<8.0.0",
124-
"mypy==1.7.1",
124+
"mypy==1.18.1",
125125
"pre-commit",
126126
"pyment>=0.3.3,<0.4.0",
127127
"tox>=3.24.3",

src/zenml/integrations/bentoml/model_deployers/bentoml_model_deployer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,11 @@ def get_model_server_info(
142142
)
143143

144144
predictions_apis_urls = ""
145-
if service_instance.prediction_apis_urls is not None: # type: ignore
145+
if service_instance.prediction_apis_urls is not None:
146146
predictions_apis_urls = ", ".join(
147147
[
148148
api
149-
for api in service_instance.prediction_apis_urls # type: ignore
149+
for api in service_instance.prediction_apis_urls
150150
if api is not None
151151
]
152152
)

src/zenml/integrations/databricks/orchestrators/databricks_orchestrator_entrypoint_config.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ def run(self) -> None:
8282
wheel_package = self.entrypoint_args[WHEEL_PACKAGE_OPTION]
8383

8484
dist = distribution(wheel_package)
85-
project_root = os.path.join(dist.locate_file("."), wheel_package)
85+
project_root = os.path.join(
86+
str(dist.locate_file(".")), str(wheel_package)
87+
)
8688

8789
if project_root not in sys.path:
8890
sys.path.insert(0, project_root)

src/zenml/integrations/kubernetes/orchestrators/kubernetes_orchestrator_entrypoint.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,10 @@ def _reconstruct_nodes(
158158
)
159159
for job in job_list.items:
160160
annotations = job.metadata.annotations or {}
161-
if step_name := annotations.get(STEP_NAME_ANNOTATION_KEY, None):
162-
node = nodes[step_name]
161+
if step_name_annotation := annotations.get(
162+
STEP_NAME_ANNOTATION_KEY, None
163+
):
164+
node = nodes[str(step_name_annotation)]
163165
node.metadata["job_name"] = job.metadata.name
164166

165167
if node.status == NodeStatus.NOT_READY:

src/zenml/integrations/seldon/services/seldon_deployment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class SeldonDeploymentConfig(ServiceConfig):
7272
model_metadata: Dict[str, Any] = Field(default_factory=dict)
7373
extra_args: Dict[str, Any] = Field(default_factory=dict)
7474
is_custom_deployment: Optional[bool] = False
75-
spec: Optional[Dict[Any, Any]] = Field(default_factory=dict) # type: ignore[arg-type]
75+
spec: Optional[Dict[Any, Any]] = Field(default_factory=dict)
7676
serviceAccountName: Optional[str] = None
7777

7878
def get_seldon_deployment_labels(self) -> Dict[str, str]:

src/zenml/models/v2/base/filter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ def _handle_numeric_comparison(self, column: Any) -> Any:
290290
),
291291
}
292292

293-
return operations[self.operation](numeric_column, self.value) # type: ignore[no-untyped-call]
293+
return operations[self.operation](numeric_column, self.value)
294294
except Exception as e:
295295
raise ValueError(
296296
f"Failed to compare the column '{column}' to the "
@@ -990,7 +990,7 @@ def apply_sorting(
990990
column, operand = self.sorting_params
991991

992992
if operand == SorterOps.DESCENDING:
993-
sort_clause = desc(getattr(table, column)) # type: ignore[var-annotated]
993+
sort_clause = desc(getattr(table, column))
994994
else:
995995
sort_clause = asc(getattr(table, column))
996996

src/zenml/utils/function_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def _cli_wrapped_function(func: F) -> F:
143143
)
144144
invalid_types = {}
145145
for arg_name, arg_type, arg_default in input_args_dict:
146-
if _is_valid_optional_arg(arg_type):
146+
if arg_type is not None and _is_valid_optional_arg(arg_type):
147147
arg_type = arg_type.__args__[0]
148148
arg_name = _cli_arg_name(arg_name)
149149
if arg_type is bool:
@@ -156,7 +156,7 @@ def _cli_wrapped_function(func: F) -> F:
156156
required=False,
157157
)
158158
)
159-
elif _is_valid_collection_arg(arg_type):
159+
elif arg_type is not None and _is_valid_collection_arg(arg_type):
160160
member_type = arg_type.__args__[0]
161161
options.append(
162162
click.option(

src/zenml/utils/json_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def pydantic_encoder(obj: Any) -> Any:
114114

115115
if isinstance(obj, BaseModel):
116116
return obj.model_dump(mode="json")
117-
elif is_dataclass(obj):
117+
elif is_dataclass(obj) and not isinstance(obj, type):
118118
return asdict(obj)
119119

120120
# Check the class type and its superclasses for a matching encoder

src/zenml/utils/proxy_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,6 @@ def _inner_decorator(_cls: C) -> C:
207207
if method_name not in interface.__abstractmethods__
208208
)
209209

210-
return cast(C, _cls)
210+
return cast(C, _cls) # type: ignore[redundant-cast]
211211

212212
return _inner_decorator

src/zenml/utils/string_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def substitute_string(value: V, substitution_func: Callable[[str], str]) -> V:
232232

233233
model_values[k] = new_value
234234

235-
return cast(V, type(value).model_validate(model_values))
235+
return cast(V, type(value).model_validate(model_values)) # type: ignore[redundant-cast]
236236
elif isinstance(value, Dict):
237237
return cast(
238238
V, {substitute_(k): substitute_(v) for k, v in value.items()}

0 commit comments

Comments
 (0)