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

Remove --fiximports helper #39274

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
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
7 changes: 2 additions & 5 deletions src/.relint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,10 @@

- name: 'namespace_pkg_all_import: import from .all of a namespace package'
hint: |
Sage library code should not import from sage.PAC.KAGE.all when sage.PAC.KAGE is an implicit
namespace package. Type import_statements("SOME_IDENTIFIER") to find a more specific import,
or use 'sage --fiximports' to fix automatically in the source file.
# Keep in sync with SAGE_ROOT/src/sage/misc/replace_dot_all.py
Sage library code should not import from sage.PAC.KAGE.all.
pattern: 'from\s+sage(|[.](arith|categories|combinat|crypto|databases|data_structures|dynamics|ext|game_theory|games|geometry|graphs|groups|interfaces|manifolds|matrix|matroids|misc|modules|monoids|numerical|probability|quadratic_forms|quivers|rings|sat|schemes|sets|stats|symbolic|tensor)[a-z0-9_.]*|[.]libs)[.]all\s+import'
# imports from .all are allowed in all.py; also allow in some modules that need sage.all
filePattern: '(.*/|)(?!(all|benchmark|dev_tools|parsing|sage_eval|explain_pickle|.*_test))[^/.]*[.](py|pyx|pxi)$'
filePattern: '(.*/|)(?!(all|benchmark|parsing|sage_eval|explain_pickle|.*_test))[^/.]*[.](py|pyx|pxi)$'

- name: 'namespace_pkg_all_import_2: Module-level import of .all of a namespace package'
hint: |
Expand Down
9 changes: 0 additions & 9 deletions src/bin/sage
Original file line number Diff line number Diff line change
Expand Up @@ -488,10 +488,6 @@ usage_advanced() {
echo " --fixdoctests file.py"
echo " -- Run doctests and replace output of failing doctests"
echo " with actual output."
echo " --fiximports <files|dirs>"
echo " -- Replace imports from sage.PAC.KAGE.all by specific"
echo " imports when sage.PAC.KAGE is an implicit namespace"
echo " package"
echo " --fixdistributions <files|dirs>"
echo " -- Check or update '# sage_setup: distribution'"
echo " directives in source files"
Expand Down Expand Up @@ -955,11 +951,6 @@ if [ "$1" = '-startuptime' -o "$1" = '--startuptime' ]; then
exec sage-startuptime.py "$@"
fi

if [ "$1" = '-fiximports' -o "$1" = '--fiximports' ]; then
shift
exec sage-python -m sage.misc.replace_dot_all "$@"
fi

if [ "$1" = '-fixdistributions' -o "$1" = '--fixdistributions' ]; then
shift
exec sage-python -m sage.misc.package_dir "$@"
Expand Down
2 changes: 0 additions & 2 deletions src/doc/en/developer/packaging_sage_library.rst
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,6 @@ distribution -- which then must be declared as a run-time dependency.
:mod:`sage.rings.all`.

To audit the Sage library for such imports, use ``sage --tox -e relint``.
In most cases, the imports can be fixed automatically using the
tool ``sage --fiximports``.

- Replace module-level imports by method-level imports. Note that
this comes with a small runtime overhead, which can become
Expand Down
7 changes: 1 addition & 6 deletions src/doc/en/faq/faq-contribute.rst
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,7 @@ necessity to import what you need.

from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing

You can use ``import_statements`` to get the exact necessary line::

sage: import_statements(PolynomialRing)
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing

If this fails, you can ask Sage where to find ``PolynomialRing`` using::
You can ask Sage where to find ``PolynomialRing`` using::

sage: PolynomialRing.__module__
'sage.rings.polynomial.polynomial_ring_constructor'
Expand Down
1 change: 0 additions & 1 deletion src/doc/en/reference/misc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@ Miscellaneous Inspection and Development Tools
sage/misc/sageinspect
sage/misc/edit_module
sage/misc/classgraph
sage/misc/dev_tools
sage/misc/function_mangling
sage/misc/rest_index_of_methods

Expand Down
8 changes: 1 addition & 7 deletions src/doc/it/faq/faq-contribute.rst
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,7 @@ preparser di Sage) e la necessità di importare quello che ti serve.

from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing

Puoi chiedere a Sage dove il comando per importare ``PolynomialRing`` usando::

sage: import_statements(PolynomialRing)
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing

Se questo fallisce, puoi chiedere a Sage dove si trove ``PolynomialRing``
usando::
Puoi chiedere a Sage dove si trove ``PolynomialRing`` usando::

sage: PolynomialRing.__module__
'sage.rings.polynomial.polynomial_ring_constructor'
Expand Down
2 changes: 1 addition & 1 deletion src/sage/features/all.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def name_feature(name, toplevel=None):
except AttributeError:
return None

from sage.misc.dev_tools import find_object_modules
from sage.misc.sageinspect import find_object_modules

for module, names in find_object_modules(obj).items():
if name in names and (feature := module_feature(module)):
Expand Down
3 changes: 0 additions & 3 deletions src/sage/misc/all.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

from sage.misc.banner import version

from sage.misc.dev_tools import import_statements

from sage.misc.html import html, pretty_print_default

from sage.misc.table import table
Expand Down Expand Up @@ -125,7 +123,6 @@
lazy_import('sage.misc.inline_fortran', 'fortran')

lazy_import('sage.misc.banner', 'banner', deprecation=34259)
lazy_import('sage.misc.dev_tools', 'runsnake', deprecation=34259)
lazy_import('sage.misc.edit_module', 'set_edit_template', deprecation=34259)
lazy_import('sage.misc.profiler', 'Profiler', deprecation=34259)
lazy_import('sage.misc.trace', 'trace', deprecation=34259)
Expand Down
Loading
Loading