-
-
Notifications
You must be signed in to change notification settings - Fork 185
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
bug: Importing from Copier prevents forcing colors with FORCE_COLOR=1 #1378
Comments
OK, I expanded the imports triggered by To be honest, although Colorama seems super simple to use, every time I have to use it I'm completely lost at how to use it correctly. Here's what I'm doing in another project of mine: import colorama
def some_entry_point(color: bool | None = None):
...
colorama.deinit()
colorama.init(strip=None if color is None else not color)
... ...which I think is not the most performant way of using it (deinit then reinit every time the function is called), but at least seems to work without messing things up 🤷 |
Reading tartley/colorama#230, my Additional note: |
Plumbum weirdness filed here: tomerfiliba/plumbum#659 |
Related: #368 |
Only fix Windows console with Colorama. Fix #1378
Describe the problem
Rich or Rich-based CLIs will print colors on regular terminals. In subprocesses, Rich detects that the process isn't attached to a TTY (or rather pseudo-TTY if I recall terminology correctly) and disables colors. Colors can be forced back using the
FORCE_COLOR=1
environment variable.Setting the variable works well... unless something is imported from Copier. This was quite hard to identify as the cause, but here's a reproduction example:
Now run
bash colors.sh
and you get an output similar to this (don't pay attention to the actual colors, I'm using a dynamic color theme based on my wallpaper thanks to pywal):See script in the "Reproduction" section for a complete script that you can copy and paste.
Template
N/A
To Reproduce
Logs
No response
Expected behavior
Importing things from Copier should not cancel the effect of
FORCE_COLOR=1
.Screenshots/screencasts/logs
No response
Operating system
Linux
Operating system distribution and version
Linux 6.5.7-arch1-1
Copier version
8.3.0
Python version
3.11.5
Installation method
pipx+pypi
Additional context
No response
The text was updated successfully, but these errors were encountered: