lintrunner icon indicating copy to clipboard operation
lintrunner copied to clipboard

Fix file handling of --all-files to properly handle non-ascii filenames.

Open aorenste opened this issue 1 year ago • 3 comments

On my setup lintrunner was failing like this:

(py39) $ lintrunner --take RUFF --all-files
error:        No such file or directory (os error 2)

The underlying error was because there's a file with non-ascii characters in the name.

There are two problems:

  1. When a file reported by git wasn't found it was reporting the error without any context about the filename.
  2. The files being returned by git are escaped by git and then passed through a utf-8 String.

This PR adds context for the names so when an error does occur the user can at least tell what file had the problem.

Additionally it changes how --all-files gets its filenames so it doesn't pass them through String (which incorrectly does utf-8 encoding on them).

There are some additional incorrect handling of paths in other areas of the code (get_paths_from_cmd for example) which should probably be fixed in a similar manner in the future (or maybe merged with the all-files handling).

aorenste avatar Apr 18 '25 19:04 aorenste

sorry for the late response—I ran the CI, mind taking a look at the issues?

suo avatar May 08 '25 16:05 suo

@suo Huh. Looks like a bunch of the CI is failing with an infra issue:

Getting action download info
Error: This request has been automatically failed because it uses a deprecated version of `actions/upload-artifact: v3`. Learn more: https://github.blog/changelog/[20](https://github.com/suo/lintrunner/actions/runs/14915998547/job/41902324071?pr=86#step:1:24)24-04-16-deprecation-notice-v3-of-the-artifact-actions/

aorenste avatar May 08 '25 21:05 aorenste

Can you give me permission to push to your branch? I want to try rebasing to see if that fixes things

suo avatar Jun 19 '25 23:06 suo