Repository: tehmaze/ansi (language: python)

Issue:
Fix setup.cfg according to the comment from mgorny

Allow importing the main module to import all submodules
Currently, to use color, one must import `ansi.color`, not just `ansi`. To use another module, e.g. `ansi.cursor` has to be imported too, and with all the submodules, this might become a mess in the import area.
This PR is meant to fix that. Because `__init__.py` can also handle aliases, I deleted `color.py`.


Discussion / hints:

thanks

Fix patch:
diff --git a/ansi/color.py b/ansi/color.py
new file mode 100644
index 0000000..f3a82b6
--- /dev/null
+++ b/ansi/color.py
@@ -0,0 +1,9 @@
+# pylint: disable=C0111,W0611,W0614
+from sys import modules
+
+import ansi.colour  # lgtm [py/import-and-import-from]
+from ansi.colour import bg, fg, fx, rgb
+
+modules["ansi.color"] = ansi.colour
+
+__all__ = ['fg', 'bg', 'fx', 'rgb']
diff --git a/ansi/cursor.py b/ansi/cursor.py
index faacdd1..ad07b71 100644
--- a/ansi/cursor.py
+++ b/ansi/cursor.py
@@ -12,7 +12,7 @@
 prev_line   = sequence('F')
 goto_x      = sequence('G')
 goto        = sequence('H', 2)
-erase       = sequence('J')
+erase       = sequence('2J')
 erase_data  = erase
 erase_line  = sequence('K')
 scroll_up   = sequence('S')


Test patch:
diff --git a/test_ansi.py b/test_ansi.py
index f2018ba..a12d704 100644
--- a/test_ansi.py
+++ b/test_ansi.py
@@ -74,3 +74,8 @@ def test_empty() -> None:
     assert fg.none('12') == '12'
     assert fg.none + '12' == '12'
     assert fx.noop + '12' == '12'
+
+def test_erase() -> None:
+    from ansi.cursor import erase, erase_data, erase_line
+    assert erase('') == erase_data('') == '\x1b[2J'
+    assert erase_line('') == '\x1b[K'