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

Error when defining python command with a function and using bracketed paste format #395

Open
Silzinc opened this issue Oct 19, 2024 · 3 comments

Comments

@Silzinc
Copy link

Silzinc commented Oct 19, 2024

Hello. I am using the following config for Python :

python = {
    command = function()
        if package.loaded["venv-selector"] then
            local venv = require("venv-selector")
            local venv_path = venv.python() 
            -- for master branch, use venv.get_active_path()
            if venv_path then
	        return { venv_path }
	    end
        end
        return { "python3" }
    end,
    format = require("iron.fts.common").bracketed_paste_python,
},

But as soon as I send something to the repl, an error occurs. It seems the bracketed_paste_python function calls the contains function in iron.fts.common treating the command as a table, and not a function. It would be nice to handle that case too, with something like this:

if type(cmd) == "function" then
    cmd = cmd(meta) -- idk where to find meta though
end

Thanks in advance !

@rambip
Copy link

rambip commented Dec 12, 2024

I have the same issue, but this time it is because my command is a string. It is not an error, I use the feature of iron that spawns a bash process when the command argument is a string and not a table with an executable and arguments.

require("iron.core").setup {
  config = {
    repl_definition = {
      python = {
        command = "source .venv/bin/activate; ipython; python",
        format = require("iron.fts.common").bracketed_paste_python
      }
    },
}

I't funny that we are both trying to make it org with venv :)

@rambip
Copy link

rambip commented Dec 12, 2024

The error seems to come from here:

dt = format(meta.repldef, dt)

and then here:

local is_ipython = contains(cmd, "ipython")

Pretty ugly to check manually if command is ipython ...

@nickeisenberg
Copy link
Contributor

nickeisenberg commented Jan 25, 2025

The is_ipython check is now only used on Windows. Does this help things? I dont have much desire to make things less ugly on Windows as most people use linux or mac.

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

No branches or pull requests

3 participants