Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I really like this pattern, but unfortunately I haven't been able to get it to work with my LSP (pyright, in Helix), even when running my editor via uv (`uv run hx script.py`).

I could always do `uv run --with whatever-it-is-i-need hx script.py`, but that's starting to get redundant.



I have my own ugly uve script

    $ cat ~/.local/bin/uve
    #!/bin/bash
    temp=$(mktemp)
    uv export --script $1 --no-hashes > $temp
    uv run --with-requirements $temp vim $1
    unlink $temp

Hope editor could support the `uv python find --script` soon.


FYI, have a look at "trap .. EXIT" to defer cleanups like your unlink. It's neat cause it will run even if the script is interrupted / fails before the unlink.


Useful tip, I suppose it will look like:

  temp=$(mktemp)
  trap 'unlink $temp' EXIT
  # Do things


Exactly. And if your cleanup is more involved you can call a cleanup function.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: