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

"colorized" ignored when called without shell?d #9445

Open
buhtz opened this issue Feb 17, 2024 · 0 comments
Open

"colorized" ignored when called without shell?d #9445

buhtz opened this issue Feb 17, 2024 · 0 comments
Labels
Documentation 📗 Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling Question

Comments

@buhtz
Copy link

buhtz commented Feb 17, 2024

Bug description

Not sure if tis is a bug. So I ask first. I can run pylint on my shell with --output-format=colorized and get the expected nice and fancy output. But when doing this in Python code via subprocess.run() there is no color and also no colorcodes in the output string.

Might it be that the colorized option is ignored by pylint because it can not detected a color supporting terminal?

I tried to do shell=True in subprocess.run() but then pylint do not find any files to lint. This is another problem. But of course having shell=True is not recommended.

Configuration

Not a config file but a unitest


    def test030_pylint(self):
        # Pylint base command
        cmd = [
            'pylint',
            '--output-format=colorized`,
            # Storing results in a pickle file is unnecessary
            '--persistent=n',
            # autodetec number of parallel jobs
            '--jobs=0',
            # Disable scoring  ("Your code has been rated at xx/10")
            '--score=n',
            # PEP8 conform line length (see PyLint Issue #3078)
            f'--max-line-length={PEP8_MAX_LINE_LENGTH}',
            # prevent false-positive no-module-member errors
            '--extension-pkg-whitelist=lxml',
            # List of members which are set dynamically and missed by pylint
            # inference system, and so shouldn't trigger E1101 when accessed.
            '--generated-members=WD_ALIGN_PARAGRAPH,WD_ORIENT,PARAGRAPH',
            # Allowlist variable names
            '--good-names=idx,fp,df',
            # Allow fstrings when logging
            '--disable=logging-fstring-interpolation',
        ]
        # Add py files
        cmd.extend(self.collected_py_files[6:7])

        # subprocess.run(cmd, check=True)
        r = subprocess.run(
            cmd,
            check=False,
            universal_newlines=True,
            capture_output=True)

        print(f'!!!!!!!!!!!!!!!! {r.stdout=}')
        print(f'!!!!!!!!!!!!1!! {r.stderr=}')
        print(f'ÖÖÖÖÖÖÖÖÖÖÖÖÖÖ {r.returncode=}')

        self.assertEqual(0, r.returncode)

Command used

See configuration

Pylint output

Returncode 28

Expected behavior

Nice colors on my terminal.

Pylint version

pylint 3.0.3                                                                                                                  astroid 3.0.2                                                                                                                 Python 3.9.2 (default, Feb 28 2021, 17:03:44)                                                                                 [GCC 10.2.1 20210110]

OS / Environment

Debian GNU Linux 12

Additional dependencies

No response

@buhtz buhtz added Documentation 📗 Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling Question labels Feb 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation 📗 Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling Question
Projects
None yet
Development

No branches or pull requests

1 participant