Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable ANSI colors on Windows 10 #3583

Merged
merged 1 commit into from
Mar 17, 2023
Merged

Enable ANSI colors on Windows 10 #3583

merged 1 commit into from
Mar 17, 2023

Conversation

charliermarsh
Copy link
Member

@charliermarsh charliermarsh commented Mar 17, 2023

Summary

It looks like our color output is failing on Windows 10 (yet we're still outputting the color markers). There's some discussion in colored-rs/colored#59, and the recommended fix is to enable the virtual terminal in that case (https://docs.rs/colored/2.0.0/x86_64-pc-windows-msvc/colored/control/fn.set_virtual_terminal.html).

Test Plan

See: #3568, where @copperfield42 tested locally before and after.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 17, 2023

PR Check Results

Ecosystem

✅ ecosystem check detected no changes.

Benchmark

Linux

group                                      main                                   pr
-----                                      ----                                   --
linter/all-rules/large/dataset.py          1.00     14.6±0.44ms     2.8 MB/sec    1.02     14.8±0.52ms     2.7 MB/sec
linter/all-rules/numpy/ctypeslib.py        1.00      3.9±0.13ms     4.3 MB/sec    1.00      3.9±0.09ms     4.3 MB/sec
linter/all-rules/numpy/globals.py          1.00   534.2±20.61µs     5.5 MB/sec    1.00   532.9±22.12µs     5.5 MB/sec
linter/all-rules/pydantic/types.py         1.00      6.4±0.25ms     4.0 MB/sec    1.00      6.4±0.21ms     4.0 MB/sec
linter/default-rules/large/dataset.py      1.01      8.0±0.20ms     5.1 MB/sec    1.00      7.9±0.21ms     5.2 MB/sec
linter/default-rules/numpy/ctypeslib.py    1.00  1791.2±67.61µs     9.3 MB/sec    1.00  1786.9±63.66µs     9.3 MB/sec
linter/default-rules/numpy/globals.py      1.00    204.3±9.43µs    14.4 MB/sec    1.02    208.1±8.80µs    14.2 MB/sec
linter/default-rules/pydantic/types.py     1.00      3.7±0.13ms     6.8 MB/sec    1.02      3.8±0.13ms     6.7 MB/sec

Windows

group                                      main                                   pr
-----                                      ----                                   --
linter/all-rules/large/dataset.py          1.01     15.8±0.13ms     2.6 MB/sec    1.00     15.6±0.10ms     2.6 MB/sec
linter/all-rules/numpy/ctypeslib.py        1.01      4.3±0.06ms     3.9 MB/sec    1.00      4.2±0.02ms     3.9 MB/sec
linter/all-rules/numpy/globals.py          1.00    463.7±4.62µs     6.4 MB/sec    1.01    467.8±8.73µs     6.3 MB/sec
linter/all-rules/pydantic/types.py         1.01      7.0±0.08ms     3.7 MB/sec    1.00      6.9±0.03ms     3.7 MB/sec
linter/default-rules/large/dataset.py      1.02      8.9±0.09ms     4.6 MB/sec    1.00      8.7±0.03ms     4.7 MB/sec
linter/default-rules/numpy/ctypeslib.py    1.01   1879.9±9.79µs     8.9 MB/sec    1.00  1858.0±25.31µs     9.0 MB/sec
linter/default-rules/numpy/globals.py      1.01    193.0±1.50µs    15.3 MB/sec    1.00    190.6±1.10µs    15.5 MB/sec
linter/default-rules/pydantic/types.py     1.01      4.0±0.02ms     6.3 MB/sec    1.00      4.0±0.06ms     6.4 MB/sec

@charliermarsh charliermarsh marked this pull request as ready for review March 17, 2023 20:23
@@ -69,6 +69,10 @@ quoting the executed command, along with the relevant file contents and `pyproje
}));
}

// Enabled ANSI colors on Windows 10.
#[cfg(windows)]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what I see everyone doing on GitHub Code Search, not sure if we can scope this any more narrowly.

@@ -69,6 +69,10 @@ quoting the executed command, along with the relevant file contents and `pyproje
}));
}

// Enabled ANSI colors on Windows 10.
#[cfg(windows)]
let _ = colored::control::set_virtual_terminal(true);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the docs this always returns Ok, and the signature is just a backwards-compatibility thing. Should we .unwrap()?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think yes, if it returns something other than Ok that is an error which would be silenced otherwise.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would assume that the LTO removes the error case.

I would prefer an assert over unwrap since we're not interested in the value

assert!(...is_ok())

@charliermarsh charliermarsh merged commit 50f9db2 into main Mar 17, 2023
@charliermarsh charliermarsh deleted the charlie/virtual branch March 17, 2023 21:34
renovate bot referenced this pull request in ixm-one/pytest-cmake-presets Mar 18, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [ruff](https://togithub.com/charliermarsh/ruff) | `^0.0.256` ->
`^0.0.257` |
[![age](https://badges.renovateapi.com/packages/pypi/ruff/0.0.257/age-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://badges.renovateapi.com/packages/pypi/ruff/0.0.257/adoption-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://badges.renovateapi.com/packages/pypi/ruff/0.0.257/compatibility-slim/0.0.256)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://badges.renovateapi.com/packages/pypi/ruff/0.0.257/confidence-slim/0.0.256)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>charliermarsh/ruff</summary>

###
[`v0.0.257`](https://togithub.com/charliermarsh/ruff/releases/tag/v0.0.257)

[Compare
Source](https://togithub.com/charliermarsh/ruff/compare/v0.0.256...v0.0.257)

<!-- Release notes generated using configuration in .github/release.yml
at main -->

#### What's Changed

##### Rules

- \[`ruff`] Prefer `itertools.pairwise()` over `zip()` for successive
pairs (`RUF007`) by
[@&#8203;evanrittenhouse](https://togithub.com/evanrittenhouse) in
[https://github.com/charliermarsh/ruff/pull/3501](https://togithub.com/charliermarsh/ruff/pull/3501)
- \[`flake8-bugbear`] Add `no-explicit-stacklevel` (`B028`) by
[@&#8203;johnor](https://togithub.com/johnor) in
[https://github.com/charliermarsh/ruff/pull/3550](https://togithub.com/charliermarsh/ruff/pull/3550)
- \[`pylint`] invalid-characters-\* by
[@&#8203;r3m0t](https://togithub.com/r3m0t) in
[https://github.com/charliermarsh/ruff/pull/3552](https://togithub.com/charliermarsh/ruff/pull/3552)
- \[`pylint`] Implement `useless-return` (`R1711`) by
[@&#8203;tomecki](https://togithub.com/tomecki) in
[https://github.com/charliermarsh/ruff/pull/3116](https://togithub.com/charliermarsh/ruff/pull/3116)
- \[`pylint`]: Implement `continue-in-finally` (`E0116`) by
[@&#8203;latonis](https://togithub.com/latonis) in
[https://github.com/charliermarsh/ruff/pull/3541](https://togithub.com/charliermarsh/ruff/pull/3541)

##### Bug Fixes

- Rewrite mock import with starred imports by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3566](https://togithub.com/charliermarsh/ruff/pull/3566)
- Respect `type` overrides in E721 by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3582](https://togithub.com/charliermarsh/ruff/pull/3582)
- Use `value > max` style in pylint and mccabe messages by
[@&#8203;edgarrmondragon](https://togithub.com/edgarrmondragon) in
[https://github.com/charliermarsh/ruff/pull/3553](https://togithub.com/charliermarsh/ruff/pull/3553)
- Fix autofix conflict between `D209` and `D400` by
[@&#8203;JonathanPlasse](https://togithub.com/JonathanPlasse) in
[https://github.com/charliermarsh/ruff/pull/3564](https://togithub.com/charliermarsh/ruff/pull/3564)
- Avoid C1901 violations within subscripts by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3517](https://togithub.com/charliermarsh/ruff/pull/3517)
- Avoid adding dashed line outside of docstring by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3581](https://togithub.com/charliermarsh/ruff/pull/3581)
- Enable ANSI colors on Windows 10 by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3583](https://togithub.com/charliermarsh/ruff/pull/3583)

#### New Contributors

- [@&#8203;johnor](https://togithub.com/johnor) made their first
contribution in
[https://github.com/charliermarsh/ruff/pull/3550](https://togithub.com/charliermarsh/ruff/pull/3550)

**Full Changelog**:
astral-sh/ruff@v0.0.256...v0.0.257

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://app.renovatebot.com/dashboard#github/ixm-one/pytest-cmake-presets).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS4xMC4yIiwidXBkYXRlZEluVmVyIjoiMzUuMTAuMiJ9-->

Signed-off-by: Renovate Bot <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
renovate bot referenced this pull request in allenporter/flux-local Mar 21, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [ruff](https://togithub.com/charliermarsh/ruff) | `==0.0.256` ->
`==0.0.257` |
[![age](https://badges.renovateapi.com/packages/pypi/ruff/0.0.257/age-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://badges.renovateapi.com/packages/pypi/ruff/0.0.257/adoption-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://badges.renovateapi.com/packages/pypi/ruff/0.0.257/compatibility-slim/0.0.256)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://badges.renovateapi.com/packages/pypi/ruff/0.0.257/confidence-slim/0.0.256)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>charliermarsh/ruff</summary>

###
[`v0.0.257`](https://togithub.com/charliermarsh/ruff/releases/tag/v0.0.257)

[Compare
Source](https://togithub.com/charliermarsh/ruff/compare/v0.0.256...v0.0.257)

<!-- Release notes generated using configuration in .github/release.yml
at main -->

#### What's Changed

##### Rules

- \[`ruff`] Prefer `itertools.pairwise()` over `zip()` for successive
pairs (`RUF007`) by
[@&#8203;evanrittenhouse](https://togithub.com/evanrittenhouse) in
[https://github.com/charliermarsh/ruff/pull/3501](https://togithub.com/charliermarsh/ruff/pull/3501)
- \[`flake8-bugbear`] Add `no-explicit-stacklevel` (`B028`) by
[@&#8203;johnor](https://togithub.com/johnor) in
[https://github.com/charliermarsh/ruff/pull/3550](https://togithub.com/charliermarsh/ruff/pull/3550)
- \[`pylint`] invalid-characters-\* by
[@&#8203;r3m0t](https://togithub.com/r3m0t) in
[https://github.com/charliermarsh/ruff/pull/3552](https://togithub.com/charliermarsh/ruff/pull/3552)
- \[`pylint`] Implement `useless-return` (`R1711`) by
[@&#8203;tomecki](https://togithub.com/tomecki) in
[https://github.com/charliermarsh/ruff/pull/3116](https://togithub.com/charliermarsh/ruff/pull/3116)
- \[`pylint`]: Implement `continue-in-finally` (`E0116`) by
[@&#8203;latonis](https://togithub.com/latonis) in
[https://github.com/charliermarsh/ruff/pull/3541](https://togithub.com/charliermarsh/ruff/pull/3541)

##### Bug Fixes

- Rewrite mock import with starred imports by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3566](https://togithub.com/charliermarsh/ruff/pull/3566)
- Respect `type` overrides in E721 by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3582](https://togithub.com/charliermarsh/ruff/pull/3582)
- Use `value > max` style in pylint and mccabe messages by
[@&#8203;edgarrmondragon](https://togithub.com/edgarrmondragon) in
[https://github.com/charliermarsh/ruff/pull/3553](https://togithub.com/charliermarsh/ruff/pull/3553)
- Fix autofix conflict between `D209` and `D400` by
[@&#8203;JonathanPlasse](https://togithub.com/JonathanPlasse) in
[https://github.com/charliermarsh/ruff/pull/3564](https://togithub.com/charliermarsh/ruff/pull/3564)
- Avoid C1901 violations within subscripts by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3517](https://togithub.com/charliermarsh/ruff/pull/3517)
- Avoid adding dashed line outside of docstring by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3581](https://togithub.com/charliermarsh/ruff/pull/3581)
- Enable ANSI colors on Windows 10 by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3583](https://togithub.com/charliermarsh/ruff/pull/3583)

#### New Contributors

- [@&#8203;johnor](https://togithub.com/johnor) made their first
contribution in
[https://github.com/charliermarsh/ruff/pull/3550](https://togithub.com/charliermarsh/ruff/pull/3550)

**Full Changelog**:
astral-sh/ruff@v0.0.256...v0.0.257

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://app.renovatebot.com/dashboard#github/allenporter/flux-local).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS4xNC4yIiwidXBkYXRlZEluVmVyIjoiMzUuMTQuMiJ9-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants