Skip to content

fix[pydantic]: Manage pydantic Field.deprecated attribute#458

Merged
maxenceprog merged 2 commits into
mainfrom
86-deprecation-warnings-are-shown-even-if-the-field-is-not-accessed-in-the-task
Jun 25, 2026
Merged

fix[pydantic]: Manage pydantic Field.deprecated attribute#458
maxenceprog merged 2 commits into
mainfrom
86-deprecation-warnings-are-shown-even-if-the-field-is-not-accessed-in-the-task

Conversation

@maxenceprog

Copy link
Copy Markdown
Contributor

finally the simplest implementation was to ignore warning only if input is missing.

-> The input is not given by user : No warning

-> The input IS given by user : Deprecation Warning

Note : Default behavior in python is to ignore DeprecationWarning (except in main module). This default behaviour can be overrided (ie: python -W default)

@codecov

codecov Bot commented Jun 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Comment thread src/ewokscore/tests/test_task_input_model.py Outdated
Comment thread src/ewokscore/task.py Outdated
Comment on lines +163 to +166
if self.__inputs[name].is_missing():
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
self.__inputs[name].value = getattr(model, name)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I fear this is not clear enough that we want to suppress the DeprecationWarning coming from deprecated fields.

Maybe add a comment? Or make it more explcit in the code:

is_deprecated = self._INPUT_MODEL.model_fields[name].deprecated
not_supplied = self.__inputs[name].is_missing()

if is_deprecated and not_supplied:
    ....

@maxenceprog maxenceprog requested a review from loichuder June 23, 2026 12:54
@maxenceprog maxenceprog merged commit 5438993 into main Jun 25, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deprecation warnings are shown even if the field is not accessed in the task

2 participants