Skip to content

Unexpected TRY400 indicated in unchanged code #292

@jaraco

Description

@jaraco

In the feature/compilers-module-redux branch, I'm attempting to refactor the code. When I do, a TRY400 error is indicated even though the code hasn't changed:

__________________________________________________________________ test session ___________________________________________________________________
distutils/compilers/C/msvc.py:163:9: TRY400 Use `logging.exception` instead of `logging.error`
    |
161 |         ).decode('utf-16le', errors='replace')
162 |     except subprocess.CalledProcessError as exc:
163 |         log.error(exc.output)
    |         ^^^^^^^^^^^^^^^^^^^^^ TRY400
164 |         raise DistutilsPlatformError(f"Error executing {exc.cmd}")
    |
    = help: Replace with `exception`

First off, that's a nuisance error. What if what I really wanted was to log just the error message? Ruff shouldn't be griping about legitimate usage of supported interfaces. If logging.error shouldn't ever be used, they should file that as a feature change to CPython to get that functionality deprecated.

Second, why is this error only emitted in the branch (bac29f1), when the same code succeeds just fine in main?

@DimitriPapadopoulos What do you make of this error?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions