Repository: yt-dlp/yt-dlp
File: yt_dlp/YoutubeDL.py (Python)

Code before:
            out=stdout,
            error=sys.stderr,
            screen=sys.stderr if self.params.get('quiet') else stdout,
            console=None if compat_os_name == 'nt' else next(
                filter(supports_terminal_sequences, (sys.stderr, sys.stdout)), None)
        )

        try:
            windows_enable_vt_mode()
        except Exception as e:
            self.write_debug(f'Failed to enable VT mode: {e}')

        if self.params.get('no_color'):
            if self.params.get('color') is not None:
                self.report_warning('Overwriting params from "color" with "no_color"')
            self.params['color'] = 'no_color'

        term_allow_color = os.environ.get('TERM', '').lower() != 'dumb'

        def process_color_policy(stream):
            stream_name = {sys.stdout: 'stdout', sys.stderr: 'stderr'}[stream]
            policy = traverse_obj(self.params, ('color', (stream_name, None), {str}), get_all=False)
            if policy in ('auto', None):
                return term_allow_color and supports_terminal_sequences(stream)
            return {'always': True, 'never': False}.get(policy, policy)

        self._allow_colors = Namespace(**{
            name: process_color_policy(stream)
            for name, stream in self._out_files.items_ if name != 'console'
        })
        print(self._allow_colors)

        # The code is left like this to be reused for future deprecations
        MIN_SUPPORTED, MIN_RECOMMENDED = (3, 7), (3, 7)
        current_version = sys.version_info[:2]
        if current_version < MIN_RECOMMENDED:
            msg = ('Support for Python version %d.%d has been deprecated. '
                   'See  https://github.com/yt-dlp/yt-dlp/issues/3764  for more details.'
                   '\n                    You will no longer receive updates on this version')
            if current_version < MIN_SUPPORTED:
                msg = 'Python version %d.%d is no longer supported'
            self.deprecated_feature(
                f'{msg}! Please update to Python %d.%d or above' % (*current_version, *MIN_RECOMMENDED))

        if self.params.get('allow_unplayable_formats'):
            self.report_warning(
                f'You have asked for {self._format_err("UNPLAYABLE", self.Styles.EMPHASIS)} formats to be listed/downloaded. '
                'This is a developer option intended for debugging. \n'
                '         If you experience any issues while using this option, '
                f'{self._format_err("DO NOT", self.Styles.ERROR)} open a bug report')


Review comment (suggestion):
Pls add back the assert. We don't want to support arbitrary values. Also, I don't think `{str}` is needed.

Code after:
            out=stdout,
            error=sys.stderr,
            screen=sys.stderr if self.params.get('quiet') else stdout,
            console=None if compat_os_name == 'nt' else next(
                filter(supports_terminal_sequences, (sys.stderr, sys.stdout)), None)
        )

        try:
            windows_enable_vt_mode()
        except Exception as e:
            self.write_debug(f'Failed to enable VT mode: {e}')

        if self.params.get('no_color'):
            if self.params.get('color') is not None:
                self.report_warning('Overwriting params from "color" with "no_color"')
            self.params['color'] = 'no_color'

        term_allow_color = os.environ.get('TERM', '').lower() != 'dumb'

        def process_color_policy(stream):
            stream_name = {sys.stdout: 'stdout', sys.stderr: 'stderr'}[stream]
            policy = traverse_obj(self.params, ('color', (stream_name, None), {str}), get_all=False)
            if policy in ('auto', None):
                return term_allow_color and supports_terminal_sequences(stream)
            assert policy in ('always', 'never', 'no_color')
            return {'always': True, 'never': False}.get(policy, policy)

        self._allow_colors = Namespace(**{
            name: process_color_policy(stream)
            for name, stream in self._out_files.items_ if name != 'console'
        })

        # The code is left like this to be reused for future deprecations
        MIN_SUPPORTED, MIN_RECOMMENDED = (3, 7), (3, 7)
        current_version = sys.version_info[:2]
        if current_version < MIN_RECOMMENDED:
            msg = ('Support for Python version %d.%d has been deprecated. '
                   'See  https://github.com/yt-dlp/yt-dlp/issues/3764  for more details.'
                   '\n                    You will no longer receive updates on this version')
            if current_version < MIN_SUPPORTED:
                msg = 'Python version %d.%d is no longer supported'
            self.deprecated_feature(
                f'{msg}! Please update to Python %d.%d or above' % (*current_version, *MIN_RECOMMENDED))

        if self.params.get('allow_unplayable_formats'):
            self.report_warning(
                f'You have asked for {self._format_err("UNPLAYABLE", self.Styles.EMPHASIS)} formats to be listed/downloaded. '
                'This is a developer option intended for debugging. \n'
                '         If you experience any issues while using this option, '
                f'{self._format_err("DO NOT", self.Styles.ERROR)} open a bug report')