Repository: Delgan/loguru
Pull request #1288 (2025-02-01 14:46:41)

Bump pre-commit from 4.0.1 to 4.1.0
Bumps [pre-commit](https://github.com/pre-commit/pre-commit) from 4.0.1 to 4.1.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/pre-commit/pre-commit/releases">pre-commit's releases</a>.</em></p>
<blockquote>
<h2>pre-commit v4.1.0</h2>
<h3>Features</h3>
<ul>
<li>Add <code>language: julia</code>.
<ul>
<li><a href="https://redirect.github.com/pre-commit/pre-commit/issues/3348">#3348</a> PR by <a href="https://github.com/fredrikekre"><code>@​fredrikekre</code></a>.</li>
<li><a href="https://redirect.github.com/pre-commit/pre-commit/issues/2689">#2689</a> issue <a href="https://github.com/jmuchovej"><code>@​jmuchovej</code></a>.</li>
</ul>
</li>
</ul>
<h3>Fixes</h3>
<ul>
<li>Disable automatic toolchain switching for <code>language: golang</code>.
<ul>
<li><a href="https://redirect.github.com/pre-commit/pre-commit/issues/3304">#3304</a> PR by <a href="https://github.com/AleksaC"><code>@​AleksaC</code></a>.</li>
<li><a href="https://redirect.github.com/pre-commit/pre-commit/issues/3300">#3300</a> issue by <a href="https://github.com/AleksaC"><code>@​AleksaC</code></a>.</li>
<li><a href="https://redirect.github.com/pre-commit/pre-commit/issues/3149">#3149</a> issue by <a href="https://github.com/nijel"><code>@​nijel</code></a>.</li>
</ul>
</li>
<li>Fix <code>language: r</code> installation when initiated by RStudio.
<ul>
<li><a href="https://redirect.github.com/pre-commit/pre-commit/issues/3389">#3389</a> PR by <a href="https://github.com/lorenzwalthert"><code>@​lorenzwalthert</code></a>.</li>
<li><a href="https://redirect.github.com/pre-commit/pre-commit/issues/3385">#3385</a> issue by <a href="https://github.com/lorenzwalthert"><code>@​lorenzwalthert</code></a>.</li>
</ul>
</li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/pre-commit/pre-commit/blob/main/CHANGELOG.md">pre-commit's changelog</a>.</em></p>
<blockquote>
<h1>4.1.0 - 2025-01-20</h1>
<h3>Features</h3>
<ul>
<li>Add <code>language: julia</code>.
<ul>
<li><a href="https://redirect.github.com/pre-commit/pre-commit/issues/3348">#3348</a> PR by <a href="https://github.com/fredrikekre"><code>@​fredrikekre</code></a>.</li>
<li><a href="https://redirect.github.com/pre-commit/pre-commit/issues/2689">#2689</a> issue <a href="https://github.com/jmuchovej"><code>@​jmuchovej</code></a>.</li>
</ul>
</li>
</ul>
<h3>Fixes</h3>
<ul>
<li>Disable automatic toolchain switching for <code>language: golang</code>.
<ul>
<li><a href="https://redirect.github.com/pre-commit/pre-commit/issues/3304">#3304</a> PR by <a href="https://github.com/AleksaC"><code>@​AleksaC</code></a>.</li>
<li><a href="https://redirect.github.com/pre-commit/pre-commit/issues/3300">#3300</a> issue by <a href="https://github.com/AleksaC"><code>@​AleksaC</code></a>.</li>
<li><a href="https://redirect.github.com/pre-commit/pre-commit/issues/3149">#3149</a> issue by <a href="https://github.com/nijel"><code>@​nijel</code></a>.</li>
</ul>
</li>
<li>Fix <code>language: r</code> installation when initiated by RStudio.
<ul>
<li><a href="https://redirect.github.com/pre-commit/pre-commit/issues/3389">#3389</a> PR by <a href="https://github.com/lorenzwalthert"><code>@​lorenzwalthert</code></a>.</li>
<li><a href="https://redirect.github.com/pre-commit/pre-commit/issues/3385">#3385</a> issue by <a href="https://github.com/lorenzwalthert"><code>@​lorenzwalthert</code></a>.</li>
</ul>
</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/pre-commit/pre-commit/commit/b152e922ef11a97efe22ca7dc4f90011f0d1711c"><code>b152e92</code></a> v4.1.0</li>
<li><a href="https://github.com/pre-commit/pre-commit/commit/c3125a4d36912c768bfa5dcb2b79d6f4179d79ed"><code>c3125a4</code></a> Merge pull request <a href="https://redirect.github.com/pre-commit/pre-commit/issues/3389">#3389</a> from lorenzwalthert/dev-always-unset-renv</li>
<li><a href="https://github.com/pre-commit/pre-commit/commit/c2c061cf63e00a3ff8c88a9054c47e96a36f2daa"><code>c2c061c</code></a> fix: ensure env patch is applied for vanilla emulation</li>
<li><a href="https://github.com/pre-commit/pre-commit/commit/cd429db5e2172e51099716efd58a15e76a1719a7"><code>cd429db</code></a> Merge pull request <a href="https://redirect.github.com/pre-commit/pre-commit/issues/3382">#3382</a> from pre-commit/pre-commit-ci-update-config</li>
<li><a href="https://github.com/pre-commit/pre-commit/commit/9b9f8e254d46da65c8544244c423596d54260e24"><code>9b9f8e2</code></a> [pre-commit.ci] pre-commit autoupdate</li>
<li><a href="https://github.com/pre-commit/pre-commit/commit/86300a4a7e5441aad007d83c1101d8a8eb767ad7"><code>86300a4</code></a> Merge pull request <a href="https://redirect.github.com/pre-commit/pre-commit/issues/3376">#3376</a> from pre-commit/r-gone</li>
<li><a href="https://github.com/pre-commit/pre-commit/commit/77edad8455e88b403e055d2692c9545085cf3edb"><code>77edad8</code></a> install r on ubuntu runners</li>
<li><a href="https://github.com/pre-commit/pre-commit/commit/18b393905e24c730eeb15754f6f275a9d27e396f"><code>18b3939</code></a> Merge pull request <a href="https://redirect.github.com/pre-commit/pre-commit/issues/3375">#3375</a> from pre-commit/dotnet-tests-ubuntu-latest</li>
<li><a href="https://github.com/pre-commit/pre-commit/commit/31cb945ffb860f6f8176642d1a27af40eeec554d"><code>31cb945</code></a> Merge pull request <a href="https://redirect.github.com/pre-commit/pre-commit/issues/3374">#3374</a> from pre-commit/docker-image-tests-ubuntu-22-not-pre...</li>
<li><a href="https://github.com/pre-commit/pre-commit/commit/28c3d81bd27fe5e62eead459c1963a582e763bd7"><code>28c3d81</code></a> update .net tests to use .net 8</li>
<li>Additional commits viewable in <a href="https://github.com/pre-commit/pre-commit/compare/v4.0.1...v4.1.0">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=pre-commit&package-manager=pip&previous-version=4.0.1&new-version=4.1.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>


Patch:
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 901f511..5adf50f 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -4,7 +4,7 @@
 - Fix a regression preventing formatting of ``record["time"]`` when using ``zoneinfo.ZoneInfo`` timezones (`#1260 <https://github.com/Delgan/loguru/pull/1260>`_, thanks `@bijlpieter <https://github.com/bijlpieter>`_).
 - Allow the ``rotation`` argument of file sinks to accept a list of rotation conditions, any of which can trigger the rotation (`#1174 <https://github.com/Delgan/loguru/issues/1174>`_, thanks `@CollinHeist <https://github.com/CollinHeist>`_).
 - Update the default log format to include the timezone offset since it produces less ambiguous logs (`#856 <https://github.com/Delgan/loguru/pull/856>`_, thanks `@tim-x-y-z <https://github.com/tim-x-y-z>`_).
-
+- Add requirement for ``$TERM`` not to be ``"dumb"`` to enable colorization (`#1287 <https://github.com/Delgan/loguru/pull/1287>`_, thanks `@snosov1 <https://github.com/snosov1>`_).
 
 `0.7.3`_ (2024-12-06)
 =====================
diff --git a/loguru/_colorama.py b/loguru/_colorama.py
index 3a93931..3f6db2f 100644
--- a/loguru/_colorama.py
+++ b/loguru/_colorama.py
@@ -29,6 +29,8 @@ def should_colorize(stream):
             return True
         if "PYCHARM_HOSTED" in os.environ:
             return True
+        if os.environ.get("TERM", "") in ("dumb",):
+            return False
         if os.name == "nt" and "TERM" in os.environ:
             return True
 
diff --git a/pyproject.toml b/pyproject.toml
index 32be443..5a16673 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -42,7 +42,7 @@ requires-python = ">=3.5,<4.0"
 [project.optional-dependencies]
 dev = [
   # Setup.
-  "pre-commit==4.0.1 ; python_version>='3.9'",
+  "pre-commit==4.1.0 ; python_version>='3.9'",
   "tox==3.27.1 ; python_version<'3.8'",
   "tox==4.23.2 ; python_version>='3.8'",
   # Testing framework.


Test patch:
diff --git a/tests/test_colorama.py b/tests/test_colorama.py
index cf98721..49a0d7f 100644
--- a/tests/test_colorama.py
+++ b/tests/test_colorama.py
@@ -135,6 +135,24 @@ def test_mintty_fixed_windows(monkeypatch, patched, expected):
         assert should_colorize(stream) is expected
 
 
+@pytest.mark.parametrize(
+    ("patched", "expected"),
+    [
+        ("__stdout__", False),
+        ("__stderr__", False),
+        ("stdout", True),
+        ("stderr", True),
+        ("", True),
+    ],
+)
+def test_dumb_term_not_colored(monkeypatch, patched, expected):
+    stream = StreamIsattyTrue()
+    with monkeypatch.context() as context:
+        context.setitem(os.environ, "TERM", "dumb")
+        context.setattr(sys, patched, stream, raising=False)
+        assert should_colorize(stream) is expected
+
+
 @pytest.mark.parametrize(
     ("patched", "expected"),
     [