Skip to content

Emit prominent MigrationWarning instead of breaking InferenceData import#2575

Merged
aloctavodia merged 3 commits intoarviz-devs:mainfrom
michaelosthege:un-break-imports
Apr 24, 2026
Merged

Emit prominent MigrationWarning instead of breaking InferenceData import#2575
aloctavodia merged 3 commits intoarviz-devs:mainfrom
michaelosthege:un-break-imports

Conversation

@michaelosthege
Copy link
Copy Markdown
Contributor

The 1.0 release is not even a week old and I already have colleagues running into import errors :(

In today's case it's with cases where we have PyMC versions pinnend and the import in PyMC at the time was not yet ArviZ 1.0 compatible.

Please consider this PR which will still bombard users with prominent deprecation warnings upon import, but give library maintainers and dev-ops people some time to fix all the places that are not directly under the control of the end user.

Comment thread src/arviz/__init__.py Outdated

class MigrationError(RuntimeError):
"""Error raised when a legacy name is accessed on the ``arviz`` namespace."""
class MigrationWarning(DeprecationWarning):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
class MigrationWarning(DeprecationWarning):
class MigrationWarning(FutureWarning):

DeprecationWarning is intended for devs and is less visible than FutureWarning.

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 would actually argue it should be a subclass of UserWarning. It is very much a present issue and the vast majority of InferenceData use will be broken now. Only type hints, and things like isinstance(...) or calling a handful of methods without keyword arguments will continue to work.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I subclassed it from both warning types; UserWarning first

Comment thread src/arviz/__init__.py
@aloctavodia
Copy link
Copy Markdown
Contributor

The 1.0 release was more than one month ago. But yeah, we can consider this PR.

@aloctavodia
Copy link
Copy Markdown
Contributor

The error with the docs is unrelated to this PR and it has been addressed elsewhere.

@aloctavodia aloctavodia mentioned this pull request Apr 23, 2026
@zaxtax
Copy link
Copy Markdown
Contributor

zaxtax commented Apr 23, 2026

I also support this PR!

@aloctavodia aloctavodia merged commit 4d63d60 into arviz-devs:main Apr 24, 2026
3 of 4 checks passed
@michaelosthege michaelosthege deleted the un-break-imports branch April 24, 2026 08:15
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.

4 participants