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

pants fmt sometimes ignoring pyproject.toml? #13886

Closed
ryanking opened this issue Dec 14, 2021 · 3 comments
Closed

pants fmt sometimes ignoring pyproject.toml? #13886

ryanking opened this issue Dec 14, 2021 · 3 comments
Labels

Comments

@ryanking
Copy link
Contributor

Describe the bug
I think that pants is sometimes ignoring our pyproject.toml file, specifically tool.isort.known_first_party.

Pants version

$ ./pants version
2.8.0

OS
MacOS

Additional info

When running fmt across he whole repo, I have to use xargs to chunk the files due to #13462. When I do that, pants seems to ignore our config and reformat imports which are in known_first_party. My coworker on Linux, which has a higher MAX_ARGS and therefore does not need xargs does not see this problem.

$ ./pants list src/:: --list-sep="\0" | xargs -n1000 -0 ./pants fmt 
<snip>
Fixing src/util/tests/test_tee.py
Fixing src/util/tests/test_tokens.py
Fixing src/util/testutil.py
Fixing src/util/text_mailer.py
Fixing src/util/usps.py



+ Black made changes.
+ isort made changes.
+ shfmt made changes.

(there should be no changes to isort, black and shfmt expected)

However, when I run ./pants fmt directly on the targets in question it works fine:

$ ./pants fmt src/util/
15:47:58.83 [INFO] Completed: Format with Black - Black made no changes.
All done! ✨ 🍰 ✨
66 files left unchanged.


15:47:59.62 [INFO] Completed: Format with isort - isort made no changes.

✓ Black made no changes.
✓ isort made no changes.

It seems that all (or almost all) the changes I find are modules listed in known_first_party being shuffled.

@ryanking ryanking added the bug label Dec 14, 2021
@Eric-Arellano
Copy link
Contributor

Hey @ryanking sorry for the delay, slower responses than normal with the holidays. I wonder if you've seen this tip? https://www.pantsbuild.org/docs/python-linters-and-formatters#isort-possible-issues-with-its-import-classifier-algorithm

You're note alone with isort 5's import classifier algorithm not playing well with Pants, and that was a problem for pantsbuild/pants itself.

To confirm that Pants is indeed picking up pyproject.toml, you can use --no-process-execution-local-cleanup (called --no-process-cleanup in 2.9+): https://www.pantsbuild.org/docs/troubleshooting#debug-tip-inspect-the-sandbox-with---no-process-execution-local-cleanup

@Eric-Arellano
Copy link
Contributor

Hey Ryan, is this still happening?

@ryanking
Copy link
Contributor Author

I think we have this all resolved now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants