Skip to content

Conversation

bcdurak
Copy link
Contributor

@bcdurak bcdurak commented Oct 14, 2025

Describe changes

I implemented/fixed _ to achieve _.

Pre-requisites

Please ensure you have done the following:

  • I have read the CONTRIBUTING.md document.
  • I have added tests to cover my changes.
  • I have based my new branch on develop and the open PR is targeting develop. If your branch wasn't based on develop read Contribution guide on rebasing branch to develop.
  • IMPORTANT: I made sure that my changes are reflected properly in the following resources:
    • ZenML Docs
    • Dashboard: Needs to be communicated to the frontend team.
    • Templates: Might need adjustments (that are not reflected in the template tests) in case of non-breaking changes and deprecations.
    • Projects: Depending on the version dependencies, different projects might get affected.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Other (add details above)

@bcdurak bcdurak changed the title mypy changes Upgrading mypy Oct 14, 2025
@github-actions github-actions bot added internal To filter out internal PRs and issues enhancement New feature or request labels Oct 14, 2025
Copy link

socket-security bot commented Oct 14, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedmypy@​1.7.1 ⏵ 1.18.175 +1100100100100

View full report

Base automatically changed from feature/managing-python-versions to develop October 15, 2025 15:02
@bcdurak bcdurak requested a review from schustmi October 15, 2025 15:07
@bcdurak bcdurak linked an issue Oct 16, 2025 that may be closed by this pull request
1 task
annotations = job.metadata.annotations or {}
if step_name := annotations.get(STEP_NAME_ANNOTATION_KEY, None):
node = nodes[step_name]
if step_name_annotation_key := annotations.get(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The result of this is not a key, but a value. It's the value step_name, which is what the variable was (and should be) IMO

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable step_name is already used at this point, which leads to:

src/zenml/integrations/kubernetes/orchestrators/kubernetes_orchestrator_entrypoint.py:161: error: Incompatible types in assignment (expression has type "Any | None", variable has type "str")

You are right though, it is not a key. I have changed it now to step_name_annotation, would it be ok for you?

if isinstance(obj, BaseModel):
return obj.model_dump(mode="json")
elif is_dataclass(obj):
elif is_dataclass(obj) and not isinstance(obj, type):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this necessary? This seems like not just a linting adjustment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_dataclass returns True if obj is a dataclass itself or if it's an instance of a dataclass. However, the asdict in the next line only accepts instances and mypy raises:

src/zenml/utils/json_utils.py:118: error: Argument 1 to "asdict" has incompatible type "DataclassInstance | type[DataclassInstance]"; expected "DataclassInstance" [arg-type]

Even in python 3.11, providing a type would lead to an error, so I doubt this changes the functionality. WDYT?

model_values[k] = new_value

return cast(V, type(value).model_validate(model_values))
return cast(V, type(value).model_validate(model_values)) # type: ignore[redundant-cast]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming we can't get rid of the cast entirely because this doesn't work on all python versions?

Copy link
Contributor Author

@bcdurak bcdurak Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really. If that would be the case, it would lead to an unused-ignore error on the other versions.

As for your question, I was a bit hesitant to remove the redundant casts. We used to do a few tricks with the way we handled pydantic objects and I thought removing the cast might mess up

@bcdurak bcdurak requested a review from schustmi October 17, 2025 13:29
@zenml-io zenml-io deleted a comment from github-actions bot Oct 17, 2025
@zenml-io zenml-io deleted a comment from github-actions bot Oct 17, 2025
Copy link
Contributor

Documentation Link Check Results

Absolute links check failed
There are broken absolute links in the documentation. See workflow logs for details
Relative links check passed
Last checked: 2025-10-17 14:01:37 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request internal To filter out internal PRs and issues run-slow-ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Upgrade mypy

2 participants