Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_legacy: mark legacy API as PendingDeprecationWarning #238

Closed
wants to merge 1 commit into from

Conversation

FFY00
Copy link
Member

@FFY00 FFY00 commented Oct 20, 2021

Per #80

@FFY00 FFY00 requested a review from jaraco October 20, 2021 19:10
@jaraco
Copy link
Member

jaraco commented Oct 30, 2021

On further consideration, I believe the DeprecationWarning is working as intended. In particular, the docs say:

Base category for warnings about deprecated features when those warnings are intended for other Python developers (ignored by default, unless triggered by code in __main__).

In other words, the warning should not appear for users and library maintainers should have the ability to update to account for the change over months (the intention of the deprecation). Here's a demo:

draft $ cat mod.py
__requires__ = ['importlib_resources >=5.3']

import contextlib
import importlib_resources as res

with contextlib.suppress(Exception):
    res.is_resource('mod', 'bar')
draft $ pip-run -q importlib_resources -- -c "import mod; print('done')"
done

But the warning is raised if found in __main__:

draft $ pip-run -q importlib_resources -- -m mod
/Users/jaraco/draft/mod.py:7: DeprecationWarning: is_resource is deprecated. Use files() instead. Refer to https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy for migration advice.
  res.is_resource('mod', 'bar')

The legacy interface is in fact deprecated and superseded by a superior interface and there's a nice migration path.

Let's stick with the DeprecationWarning for now unless we get more clarity from the SC that the functionality should not be deprecated in 3.11.

@jaraco jaraco closed this Oct 30, 2021
@FFY00
Copy link
Member Author

FFY00 commented Oct 30, 2021

Alright, 👍

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.

None yet

2 participants