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

Do not raise a DeprecationWarning in stripe.app_info #1168

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ per-file-ignores =
stripe/oauth_error.py: IMP102
# setup.py is required for tooling
setup.py: IMP102
# should not raise a deprecation warning since it needs
# to be imported early in `stripe/__init__.py` to avoid
# a name conflict
stripe/app_info.py: IMP102

[flake8:local-plugins]
extension =
Expand Down
5 changes: 3 additions & 2 deletions stripe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
# Configuration variables
from stripe._api_version import _ApiVersion

# We must import the app_info module eagerly before defining the app_info global
# otherwise the late import will overwrite the global
# We must import the app_info module early to populate it into
# `sys.modules`; otherwise doing `import stripe.app_info` will end up
# importing that module, and not the global `AppInfo` name from below.
import stripe.app_info
from stripe._app_info import AppInfo as AppInfo
from stripe._version import VERSION as VERSION
Expand Down
24 changes: 12 additions & 12 deletions stripe/app_info.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# -*- coding: utf-8 -*-
"""
The stripe.app_info package is deprecated, please change your
imports to import from stripe directly.
From:
from stripe.app_info import AppInfo
To:
from stripe import AppInfo
"""
from typing_extensions import TYPE_CHECKING
from warnings import warn

warn(
"""
The stripe.app_info package is deprecated, please change your
imports to import from stripe directly.
From:
from stripe.app_info import AppInfo
To:
from stripe import AppInfo
""",
DeprecationWarning,
)
# No deprecation warning is raised here, because it would happen
# on every import of `stripe/__init__.py` otherwise. Since that
# module declares its own `app_info` name, this module becomes
# practically impossible to import anyway.

if not TYPE_CHECKING:
from stripe._app_info import ( # noqa
Expand Down