Repository: astanin/python-tabulate
Pull request #93 (2020-10-01 11:39:35)

fix typos


Patch:
diff --git a/README.md b/README.md
index ce06dad..7125559 100644
--- a/README.md
+++ b/README.md
@@ -176,7 +176,7 @@ extensions](http://johnmacfarlane.net/pandoc/README.html#tables):
     eggs      451
     bacon       0
 
-`github` follows the conventions of Github flavored Markdown. It
+`github` follows the conventions of GitHub flavored Markdown. It
 corresponds to the `pipe` format without alignment colons:
 
     >>> print(tabulate(table, headers, tablefmt="github"))
@@ -668,9 +668,9 @@ as a number imply that `tabulate`:
 It may not be suitable for serializing really big tables (but who's
 going to do that, anyway?) or printing tables in performance sensitive
 applications. `tabulate` is about two orders of magnitude slower than
-simply joining lists of values with a tab, coma or other separator.
+simply joining lists of values with a tab, comma, or other separator.
 
-In the same time `tabulate` is comparable to other table
+At the same time, `tabulate` is comparable to other table
 pretty-printers. Given a 10x10 table (a list of lists) of mixed text and
 numeric data, `tabulate` appears to be slower than `asciitable`, and
 faster than `PrettyTable` and `texttable` The following mini-benchmark
@@ -714,7 +714,7 @@ On Linux `tox` expects to find executables like `python2.6`,
 `C:\Python26\python.exe`, `C:\Python27\python.exe` and
 `C:\Python34\python.exe` respectively.
 
-To test only some Python environements, use `-e` option. For example, to
+To test only some Python environments, use `-e` option. For example, to
 test only against Python 2.7 and Python 3.6, run:
 
     tox -e py27,py36
diff --git a/tabulate.py b/tabulate.py
index 5d57167..b9d2e7c 100755
--- a/tabulate.py
+++ b/tabulate.py
@@ -5,17 +5,17 @@
 from __future__ import print_function
 from __future__ import unicode_literals
 from collections import namedtuple
-from platform import python_version_tuple
+import sys
 import re
 import math
 
 
-if python_version_tuple() >= ("3", "3", "0"):
+if sys.version_info >= (3, 3):
     from collections.abc import Iterable
 else:
     from collections import Iterable
 
-if python_version_tuple()[0] < "3":
+if sys.version_info[0] < 3:
     from itertools import izip_longest
     from functools import partial
 
@@ -91,9 +91,9 @@ DataRow = namedtuple("DataRow", ["begin", "sep", "end"])
 #         headerrow
 #     --- linebelowheader ---
 #         datarow
-#     --- linebewteenrows ---
+#     --- linebetweenrows ---
 #     ... (more datarows) ...
-#     --- linebewteenrows ---
+#     --- linebetweenrows ---
 #         last datarow
 #     --- linebelow ---------
 #
@@ -540,6 +540,9 @@ _invisible_codes = re.compile(
 _invisible_codes_bytes = re.compile(
     b"\x1b\\[\\d+\\[;\\d]*m|\x1b\\[\\d*;\\d*;\\d*m"
 )  # ANSI color codes
+_invisible_codes_link = re.compile(
+    r"\x1B]8;[a-zA-Z0-9:]*;[^\x1B]+\x1B\\([^\x1b]+)\x1B]8;;\x1B\\"
+)  # Terminal hyperlinks
 
 
 def simple_separated_format(separator):
@@ -724,9 +727,15 @@ def _padnone(ignore_width, s):
 
 
 def _strip_invisible(s):
-    "Remove invisible ANSI color codes."
+    r"""Remove invisible ANSI color codes.
+
+    >>> str(_strip_invisible('\x1B]8;;https://example.com\x1B\\This is a link\x1B]8;;\x1B\\'))
+    'This is a link'
+
+    """
     if isinstance(s, _text_type):
-        return re.sub(_invisible_codes, "", s)
+        links_removed = re.sub(_invisible_codes_link, "\\1", s)
+        return re.sub(_invisible_codes, "", links_removed)
     else:  # a bytestring
         return re.sub(_invisible_codes_bytes, "", s)
 
@@ -894,7 +903,7 @@ def _column_type(strings, has_invisible=True, numparse=True):
 
 
 def _format(val, valtype, floatfmt, missingval="", has_invisible=True):
-    """Format a value accoding to its type.
+    """Format a value according to its type.
 
     Unicode is supported:
 
@@ -1022,7 +1031,7 @@ def _normalize_tabular_data(tabular_data, headers, showindex="default"):
         elif hasattr(tabular_data, "index"):
             # values is a property, has .index => it's likely a pandas.DataFrame (pandas 0.11.0)
             keys = list(tabular_data)
-            if tabular_data.index.name is not None:
+            if showindex in ["default", "always", True] and tabular_data.index.name is not None:
                 if isinstance(tabular_data.index.name, list):
                     keys[:0] = tabular_data.index.name
                 else:
@@ -1469,6 +1478,8 @@ def tabulate(
     )
 
     has_invisible = re.search(_invisible_codes, plain_text)
+    if not has_invisible:
+        has_invisible = re.search(_invisible_codes_link, plain_text)
     enable_widechars = wcwidth is not None and WIDE_CHARS_MODE
     if (
         not isinstance(tablefmt, TableFormat)
diff --git a/tox.ini b/tox.ini
index c9f4e98..a20b325 100644
--- a/tox.ini
+++ b/tox.ini
@@ -8,7 +8,7 @@
 # for testing and it is disabled by default.
 
 [tox]
-envlist = lint, py27, py35, py36, py37, py38
+envlist = lint, py27, py35, py36, py37, py38, py39, py310
 
 [testenv]
 commands = pytest -v --doctest-modules --ignore benchmark.py
@@ -97,6 +97,40 @@ deps =
     pandas
     wcwidth
 
+
+[testenv:py39]
+basepython = python3.9
+commands = pytest -v --doctest-modules --ignore benchmark.py
+deps =
+    pytest
+
+[testenv:py39-extra]
+basepython = python3.9
+commands = pytest -v --doctest-modules --ignore benchmark.py
+deps =
+    pytest
+    numpy
+    pandas
+    wcwidth
+
+
+[testenv:py310]
+basepython = python3.10
+commands = pytest -v --doctest-modules --ignore benchmark.py
+deps =
+    pytest
+
+[testenv:py310-extra]
+basepython = python3.10
+setenv = PYTHONDEVMODE = 1
+commands = pytest -v --doctest-modules --ignore benchmark.py
+deps =
+    pytest
+    numpy
+    pandas
+    wcwidth
+
+
 [flake8]
 max-complexity = 22
 max-line-length = 99


Test patch:
diff --git a/test/test_output.py b/test/test_output.py
index 0e72c71..061d302 100644
--- a/test/test_output.py
+++ b/test/test_output.py
@@ -1363,7 +1363,8 @@ def test_pandas_without_index():
         import pandas
 
         df = pandas.DataFrame(
-            [["one", 1], ["two", None]], columns=["string", "number"], index=["a", "b"]
+            [["one", 1], ["two", None]], columns=["string", "number"],
+            index=pandas.Index(["a", "b"], name="index")
         )
         expected = "\n".join(
             [