Repository: cleanlab/cleanlab

Issue:
Revert version upper bound of termcolor dependency
## Background

In #905 , an upper bound to the version of termcolor was added. This was a temporary fix to pass CI on existing PRs.

https://github.com/cleanlab/cleanlab/blob/4ac43c0a2654179732cafc704e807c3c5c9ec1f1/setup.py#L108

Without the upper bound, the following tests fail on Python 3.8+
https://github.com/cleanlab/cleanlab/blob/4ac43c0a2654179732cafc704e807c3c5c9ec1f1/tests/test_token_classification.py#L134-L169

Here's a screenshot of a CI run with these tests failing:

<img width="1142" alt="image" src="https://github.com/cleanlab/cleanlab/assets/18127060/2d371cf4-0d73-49e7-8392-df3384c46a71">

It looks like the `colored`  variable no longer has the

## Task


The version limits need to be reverted to

```python
 "termcolor>=2.0.0", 
```

but the affected unit tests need to pass as well when the new release of termcolor ([version 2.4.0](https://github.com/termcolor/termcolor/releases/tag/2.4.0)) is installed.









Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -70,10 +70,10 @@ def run(self):
         "Natural Language :: English",
         # We believe this package works will these versions, but we do not guarantee it!
         "Programming Language :: Python :: 3",
-        "Programming Language :: Python :: 3.7",
         "Programming Language :: Python :: 3.8",
         "Programming Language :: Python :: 3.9",
         "Programming Language :: Python :: 3.10",
+        "Programming Language :: Python :: 3.11",
         "Programming Language :: Python",
         "Topic :: Software Development",
         "Topic :: Scientific/Engineering",
@@ -82,7 +82,7 @@ def run(self):
         "Topic :: Software Development :: Libraries",
         "Topic :: Software Development :: Libraries :: Python Modules",
     ],
-    python_requires=">=3.7",
+    python_requires=">=3.8",
     # What does your project relate to?
     keywords="machine_learning data_cleaning confident_learning classification weak_supervision "
     "learning_with_noisy_labels unsupervised_learning datacentric_ai, datacentric",
@@ -101,11 +101,11 @@ def run(self):
     # requirements files see:
     # https://packaging.python.org/en/latest/discussions/install-requires-vs-requirements/
     install_requires=[
-        "numpy>=1.20.0",
-        "scikit-learn>=1.0",
+        "numpy>=1.22.0",
+        "scikit-learn>=1.1",
         "tqdm>=4.53.0",
-        "pandas>=1.1.5",
-        "termcolor>=2.0.0,<2.4.0",
+        "pandas>=1.4.0",
+        "termcolor>=2.4.0",
     ],
     extras_require=EXTRAS_REQUIRE,
 )


Test patch:
diff --git a/tests/test_token_classification.py b/tests/test_token_classification.py
--- a/tests/test_token_classification.py
+++ b/tests/test_token_classification.py
@@ -163,7 +163,11 @@ def test_merge_probs_with_normalization():
     ],
 )
 def test_color_sentence(monkeypatch: pytest.MonkeyPatch, sentence, word, expected):
+    import os
+
+    monkeypatch.setattr(os, "isatty", lambda fd: True)
     monkeypatch.setattr("sys.stdout.isatty", lambda: True)
+    monkeypatch.setattr("sys.stdout.fileno", lambda: 1)
 
     colored = color_sentence(sentence, word)
     assert colored == expected