Is there an easy way to tell pants to ignore symli...
# general
f
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
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
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
Sounds like Undefined Behavior, I'm not sure what Pants should be doing here? What would you expect?
f
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
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
I’ll pull together a minimal example and submit a bug
h
We could either skip formatting symlinks, or format the underlying file
That should be easy enough to do
f