sagemath/sage

Remove useless 'from . import all' from some __init__.py files

Closed this issue · 21 comments

... and similar imports of modules in the package, found via

find src/sage -name '__init__.py' | xargs grep import

Possibly some of them are needed to break circular imports, but likely not all of them.

Part of #32501.

Depends on #32506

CC: @tscrim @fchapoton

Component: refactoring

Author: Matthias Koeppe

Branch/Commit: 55ca4bc

Reviewer: Frédéric Chapoton

Issue created by migration from https://trac.sagemath.org/ticket/32507

Description changed:

--- 
+++ 
@@ -1,3 +1,5 @@
+... and similar imports of modules in the package.
+
 Possibly some of them are needed to break circular imports, but likely not all of them.
 
 Part of #32501.

Commit: 8efece0

comment:3

In src/sage/combinat/__init__.py, there is

from . import quickref
from . import tutorial

These are modules without code. Are these imports needed for anything?


New commits:

8efece0sage.graphs, sage.graphs.graph_decompositions: Remove unnecessary import of modules
comment:4

from . import all was previously discussed in #20617 comment:16

Author: Matthias Koeppe

Branch pushed to git repo; I updated commit sha1. New commits:

892f2e7Remove all 'from . import all' from __init__.py files

Changed commit from 8efece0 to 892f2e7

Description changed:

--- 
+++ 
@@ -1,4 +1,8 @@
-... and similar imports of modules in the package.
+... and similar imports of modules in the package, found via
+
+```
+find src/sage -name '__init__.py' | xargs grep import
+```
 
 Possibly some of them are needed to break circular imports, but likely not all of them.
 
comment:8

Replying to @mkoeppe:

In src/sage/combinat/__init__.py, there is

from . import quickref
from . import tutorial

These are modules without code. Are these imports needed for anything?

Also:

src/sage/categories/__init__.py:from . import primer
comment:9

I am guessing these are some kind of workarounds for the sphinx docbuild?
We can take care of them in #32508.

comment:10

looks good, but does it pass the doctests with optional - dot2tex ?

comment:11

Just tested, yes it does

comment:12

ok, thx. Then let's go

Reviewer: Frédéric Chapoton

comment:13

Thank you!

Branch pushed to git repo; I updated commit sha1 and set ticket back to needs_review. New commits:

1c106cdRemove useless 'file is not empty' comments from __init__.py files
55ca4bcMerge branch 't/32506/remove_useless__file_is_not_empty__comments_from___init___py_files' into t/32507/remove_useless__from___import_all__from_some___init___py_files

Changed commit from 892f2e7 to 55ca4bc

comment:15

Merged #32506 to remove the trivial merge conflicts

Dependencies: #32506