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
maint(fix): Add deprecation warning for accidental imports #19316
Conversation
In sympy#18245 a number of modules were removed from the list of names imported by from sympy import * This adds those names back although with most of them wrapped in an object that emits DeprecationWarning each time it is accessed.
✅ Hi, I am the SymPy bot (v158). I'm here to help you write a release notes entry. Please read the guide on how to write release notes.
Note: This comment will be updated with the latest check if you edit the pull request. You need to reload the page to see it. Click here to see the pull request description that was parsed.
|
🟠Hi, I am the SymPy bot (v158). I've noticed that some of your commits add or delete files. Since this is sometimes done unintentionally, I wanted to alert you about it. This is an experimental feature of SymPy Bot. If you have any feedback on it, please comment at sympy/sympy-bot#75. The following commits add new files:
If these files were added/deleted on purpose, you can ignore this message. |
Codecov Report
@@ Coverage Diff @@
## 1.6 #19316 +/- ##
=============================================
- Coverage 75.652% 75.615% -0.038%
=============================================
Files 651 651
Lines 169528 169549 +21
Branches 40021 40022 +1
=============================================
- Hits 128253 128205 -48
- Misses 35654 35717 +63
- Partials 5621 5627 +6 |
Does anyone want to review this? |
Is the idea when the deprecation ends to continue to also have top-level modules be removed as well? I think they should be. |
#======================================================================= | ||
|
||
|
||
class DeprecatedImportModule: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should subclass types.ModuleType.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What difference does subclassing ModuleType make?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes certain things that operate on modules work correctly. For example, help()
gives special output on modules (actually that is wrong anyway, because this doesn't inherit the docstring properly).
I also wonder if this could be an issue
>>> from sympy import ode as ode1
>>> from sympy.solvers import ode as ode2
>>> ode1 == ode2
False
It might or might not be an issue, I'm not sure. I guess if this turns out to cause problems, we can do a patch release that removes it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd prefer the help to be a message saying that you haven't imported the module in the right way (if there is any need for help at all).
The purpose of providing these deprecated module imports is just to keep code that possibly depends on importing this way chugging along but with warnings. I don't see any need to provide any other functionality.
sympy/__init__.py
Outdated
'multipledispatch', | ||
'ntheory', | ||
'parsing', | ||
# 'physics', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe remove if this wasn't imported before?
sympy/__init__.py
Outdated
# __init__.py file. The plan is to remove them but for now they remain | ||
# importable but will give a deprecation warning when used. | ||
# | ||
#======================================================================= |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand the purpose of have this comment block repeated. It refers to the names below, but there is nothing below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a bug list of names in _DEPRECATED_IMPORTS
below. The difference between these and those that are listed above is that these are deprecated and will give a deprecation warning. The ones above (in this PR currently) are not deprecated and will give no warning when used.
As I understand this, some subset of all sympy modules were imported with It also seems you could do submodule star imports:
I assume those will not get deprecation warnings with this? |
I think they don't but the mechanism could be added. However, my opinion is that submodule star imports should really be supported except for submodules that aren't already included in the main |
I don't see any way to do that with a deprecation period so if we're removing them them from star import we might as well just do it now. |
This only gives deprecation warnings for modules that were previously importable from top level. For example in sympy 1.5 you can do:
With 1.6 the name prufer would not be imported. This PR does not change that. |
If we are going to do a deprecation I think it is better to remove them together, even if we can't issue a warning for some of the cases. |
This commit clarifies the comments about what will or will not be importable in future.
Clarify comments in __init__.py add docstring for DeprecatedImportModule
@moorepants @asmeurer does this look good? If so I'll merge it and along with a fix for #19326 I can put out a second release candidate. |
I'm good with this, as long as it gives a warning on the most likely cases. Thank you for addressing my concern. |
These names were importable before sympy 1.6 by accident. They were replaced with deprecated import objects to give a warning in sympy#19316 The warnings coming from these are now seen while building the docs and are breaking the docs build in CI so this commit removes those names meaning that they will have been giving a deprecation warning in sympy 1.6 and will be removed in sympy 1.7.
These names were importable before sympy 1.6 by accident. They were replaced with deprecated import objects to give a warning in sympy#19316 The warnings coming from these are now seen while building the docs and are breaking the docs build in CI so this commit removes those names meaning that they will have been giving a deprecation warning in sympy 1.6 and will be removed in sympy 1.7.
In #18245 a number of modules were
removed from the list of names imported by
from sympy import *
This adds those names back although with most of them wrapped in an
object that emits DeprecationWarning each time it is accessed.
References to other Issues or PRs
See the discussion on the mailing list:
https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/sympy/HYo616T3EwQ/g-z6ZrNKAgAJ
Brief description of what is fixed or changed
Other comments
Release Notes
NO ENTRY