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

BLACK-ISORT linter fails on Windows when black==24.1.1 and Python==3.9 #93

Closed
justinchuby opened this issue Feb 3, 2024 · 7 comments · Fixed by #92
Closed

BLACK-ISORT linter fails on Windows when black==24.1.1 and Python==3.9 #93

justinchuby opened this issue Feb 3, 2024 · 7 comments · Fixed by #92
Labels
bug Something isn't working

Comments

@justinchuby
Copy link
Owner

justinchuby commented Feb 3, 2024

This linter processes the file with isort before sending the result to black as input to the subprocess.

In

proc = run_command(
[
sys.executable,
"-mblack",
*(("--pyi",) if filename.endswith(".pyi") else ()),
*(("--ipynb",) if filename.endswith(".ipynb") else ()),
*(("--fast",) if fast else ()),
"--stdin-filename",
filename,
"-",
],
stdin=None,
input=import_sorted,
retries=retries,
timeout=timeout,
check=True,
)
, the input argument was somehow not taken by black when black==24.1.1 on Windows, Python 3.8/Python 3.9.

Maybe consider pipeline the results instead and send it via stdin?

@justinchuby justinchuby added the bug Something isn't working label Feb 3, 2024
@justinchuby justinchuby changed the title BLACK-ISORT linter fails on Windows when black==24.1.1 BLACK-ISORT linter fails on Windows when black==24.1.1 and Python 3.9 Feb 3, 2024
@justinchuby justinchuby changed the title BLACK-ISORT linter fails on Windows when black==24.1.1 and Python 3.9 BLACK-ISORT linter fails on Windows when black==24.1.1 and Python==3.9 Feb 3, 2024
@guotuofeng
Copy link

do we try stdin?

@justinchuby
Copy link
Owner Author

It is still failing even after switching to stdin. I am not sure what is going on.

@justinchuby
Copy link
Owner Author

It has to be run within lintrunner, and python 3.9, and black==24.1.1, and Windows. Somehow the interaction among these tools and platforms caused the behavior. Does lintrunner set stdin on Windows the interfered with the tools? But only on Windows with Python 3.8/3.9?

@justinchuby
Copy link
Owner Author

I am trying to debug with black to make sure stdin is not empty when accepted by black, but I haven't been able to set breakpoints in black in my current environment. I am not sure which installation it was using.

@justinchuby
Copy link
Owner Author

I suspect black somehow failed to recognize there's stuff in stdin under certain conditions.

@guotuofeng
Copy link

psf/black#4209 is created.

@justinchuby
Copy link
Owner Author

Thanks for the investigation! Good catch that I didn’t actually look into the path files and forgot they were different.

justinchuby added a commit that referenced this issue Feb 6, 2024
… black file path handling (#92)

Fixes #93. This change uses `Path().resolve()` on the file path provided
to black to avoid a bug described in
psf/black#4209.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants