https://pantsbuild.org/ logo
#general
Title
# general
f

freezing-vegetable-92896

12/01/2021, 12:43 AM
Is there an easy way to tell pants to ignore symlinks when doing
lint
. It seems black/isort end up turning the symlink into a copy of the file it links to if they are run on the file and need to make changes
h

happy-kitchen-89482

12/01/2021, 5:52 AM
Interesting use case! So you have a .py file that is a symlink to another .py file in, presumably, another directory, and the symlink is owned by some
python_sources
target?
Are there non-symlink files also owned by the same target that owns the symlink?
f

freezing-vegetable-92896

12/01/2021, 6:11 PM
Yes, A symlink in directory A to a python file in directory B. In both directories there is a
python_sources
target that owns the file or symlink as well as a pex_binary target (since the symlinked file is a script entrypoint)
running black/isort on the symlink works correctly, but running black/isort with pants replaces the symlink with a copy of the file if it makes changes
is this a bug I should be filing?
h

hundreds-father-404

12/01/2021, 6:20 PM
Sounds like Undefined Behavior, I'm not sure what Pants should be doing here? What would you expect?
f

freezing-vegetable-92896

12/01/2021, 6:37 PM
I would expect any files that are symlinks to still be symlinks after running
pants fmt
. It would be fine for it to just ignore it in this case (since we will also be `fmt`ing it’s target. It would also be acceptable for pants to write to the target of the symlink if it wants to make changes when processing the target which is a target
For example, if there was an option to
fmt_ignores_symlinks
or something, that would solve my problem here
or
no_write_to_symlink
if there are other things than
fmt
that might also write to the location in a way that would convert the symlink
e

enough-analyst-54434

12/01/2021, 7:45 PM
I think replacing a symlink with a file is definitely not undefined behavior - it's definitely always the wrong thing to do.
👍 2
We've un-dryed on your behalf un-asked.
f

freezing-vegetable-92896

12/01/2021, 8:28 PM
I’ll pull together a minimal example and submit a bug
h

happy-kitchen-89482

12/01/2021, 8:31 PM
We could either skip formatting symlinks, or format the underlying file
That should be easy enough to do
f

freezing-vegetable-92896

12/02/2021, 6:52 PM
5 Views