Skip to content

Commit 1e565a7

Browse files
committed
maint(fix): Add deprecation warning for accidental imports
Clarify comments in __init__.py add docstring for DeprecatedImportModule
1 parent 4924845 commit 1e565a7

File tree

1 file changed

+46
-25
lines changed

1 file changed

+46
-25
lines changed

sympy/__init__.py

Lines changed: 46 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -498,18 +498,18 @@ def __sympy_debug():
498498
]
499499

500500

501-
#=======================================================================
502-
#
503-
# XXX: The names below were importable before sympy 1.6 using
504-
#
505-
# from sympy import *
506-
#
507-
# This happened implicitly because there was no __all__ defined in this
508-
# __init__.py file. Not every package is imported. The list matches what
509-
# would have been imported before. It is possible that these packages will
510-
# not be imported by a star-import from sympy in future.
511-
#
512-
#=======================================================================
501+
#===========================================================================#
502+
# #
503+
# XXX: The names below were importable before sympy 1.6 using #
504+
# #
505+
# from sympy import * #
506+
# #
507+
# This happened implicitly because there was no __all__ defined in this #
508+
# __init__.py file. Not every package is imported. The list matches what #
509+
# would have been imported before. It is possible that these packages will #
510+
# not be imported by a star-import from sympy in future. #
511+
# #
512+
#===========================================================================#
513513

514514

515515
__all__.extend([
@@ -538,22 +538,43 @@ def __sympy_debug():
538538
])
539539

540540

541-
#=======================================================================
542-
#
543-
# XXX: The names listed in _DEPREACTED_IMPORTS below were importable before
544-
# sympy 1.6 using
545-
#
546-
# from sympy import *
547-
#
548-
# This happened implicitly because there was no __all__ defined in this
549-
# __init__.py file. The plan is to remove them but for now they remain
550-
# importable but will give a deprecation warning when used. In future these
551-
# names will be removed and will not be importable from here.
552-
#
553-
#=======================================================================
541+
#===========================================================================#
542+
# #
543+
# XXX: The names listed in _DEPRECATED_IMPORTS below were importable before #
544+
# sympy 1.6 using #
545+
# #
546+
# from sympy import * #
547+
# #
548+
# This happened implicitly because there was no __all__ defined in this #
549+
# __init__.py file. The plan is to remove them but for now they remain #
550+
# importable but will give a deprecation warning when used. In future these #
551+
# names will be removed and will not be importable from here. #
552+
# #
553+
#===========================================================================#
554554

555555

556556
class DeprecatedImportModule:
557+
# Add a docstring that someone can see if calling help on these objects
558+
"""Deprecated imported module object.
559+
560+
See https://github.com/sympy/sympy/pull/19316
561+
562+
This is a wrapper around a module that has been imported incorrectly.
563+
Previously this module was importable using
564+
565+
from sympy import *
566+
567+
or (for example)
568+
569+
from sympy import add
570+
571+
However it was unintentional that this module would be imported in that
572+
way and it will be removed in a future sympy version. If you do need to
573+
use this module then the correct way to import it is to give its full
574+
module path e.g.
575+
576+
import sympy.core.add as add
577+
"""
557578

558579
from sympy.utilities.exceptions import SymPyDeprecationWarning as Warn
559580
import sys

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy