null-ls.nvim icon indicating copy to clipboard operation
null-ls.nvim copied to clipboard

Import error given pylint even package is there and code is working fine

Open caamittiwari opened this issue 1 year ago • 3 comments

FAQ

  • [X] I have checked the FAQ and it didn't resolve my problem.

Issues

  • [X] I have checked existing issues and there are no issues with the same problem.

Neovim Version

neovim 9

Dev Version?

  • [ ] I am using a stable Neovim release version, or if I am using a dev version of Neovim I have confirmed that my issue is reproducible on a stable version.

Operating System

window - wsl -

Minimal Config

local M = {
  "jose-elias-alvarez/null-ls.nvim",
  event = "BufReadPre",
  commit = "60b4a7167c79c7d04d1ff48b55f2235bf58158a7",
  -- dependencies = {
  --   {
  --     "nvim-lua/plenary.nvim",
  --     commit = "9a0d3bf7b832818c042aaf30f692b081ddd58bd9",
  --     lazy = true,
  --   },
  -- },
}

function M.config()
  local null_ls = require "null-ls"
  -- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/formatting
  local formatting = null_ls.builtins.formatting
  -- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/diagnostics
  local diagnostics = null_ls.builtins.diagnostics

  -- https://github.com/prettier-solidity/prettier-plugin-solidity
  null_ls.setup {
    debug = true,
    sources = {
      formatting.prettier.with {
        extra_filetypes = { "toml" },
        extra_args = { "--no-semi", "--single-quote", "--jsx-single-quote" },
      },
      formatting.black.with { extra_args = { "--fast" } },
      formatting.stylua,
      formatting.google_java_format,
      diagnostics.pylint.with({diagnostic_config = {
            -- see :help vim.diagnostic.config()
            underline = true,
            virtual_text = false,
            signs = true,
            update_in_insert = false,
            severity_sort = true,
         },
         diagnostics_postprocess = function(diagnostic)
        diagnostic.code = diagnostic.message_id
        end,

         diagnostics_format = "[#{s}] #{m} (#{c})",
       -- command = vim.fn.system({ "which", "pylint" }):gsub("[\n]", ""),
        -- root_dir = require("null-ls.utils").root_pattern(".null-ls-root", "Makefile", ".git",'.venv'),

        }      ),
    },
  }
end

return M

Steps to Reproduce

import random import os import sys import pandas as pd import pysdafas print("hi amit ")

def amit(): age = random.choice([1, 3, 5]) print(f"amit is {age} year old")

def amitamit(name): print(name) print(name) print(name) # print(ok) def amit_a(arg): a = arg print(a)

print("amit")

def amit_b(): return random.randint(1, 2) dsfas Ok = True print("ok")

def full_name(first, last_name): return f"your full name is {first}, {last_name}"

full_name("amit", "tiwari") data = dict(name="amit", age=45) df = pd.DataFrame(data, index=["name", "age"]) p = os.getenv("PWD") + f".venv/lib/python{sys.version[:4]}/site-packages"

sys.path.append(os.path.abspath(p))

sys w.path.append(p)

print(p)

print(df)~

for i in p:

sys.path = sys.path + p

print(sys.path)

Reproducibility Check

  • [ ] I confirm that my minimal config is based on the minimal_init.lua template and that my issue is reproducible by running nvim --clean -u minimal_init.lua and following the steps above.

Expected Behavior

import error not to shown as python package pandas is there
but error code is in out put of json file code = "E0401",

Actual Behavior

import error is coming even python package pandas is there by pylint but code file is working without error but error code is in out put of json file code = "E0401",

Debug Log

[TRACE Sat 29 Apr 2023 12:59:30 PM IST] .../.local/share/nvim/lazy/null-ls.nvim/lua/null-ls/rpc.lua:127: received LSP notification for method initialized [TRACE Sat 29 Apr 2023 12:59:30 PM IST] .../.local/share/nvim/lazy/null-ls.nvim/lua/null-ls/rpc.lua:127: received LSP notification for method textDocument/didOpen [TRACE Sat 29 Apr 2023 12:59:30 PM IST] .../share/nvim/lazy/null-ls.nvim/lua/null-ls/generators.lua:21: running generators for method NULL_LS_DIAGNOSTICS_ON_OPEN [DEBUG Sat 29 Apr 2023 12:59:30 PM IST] ...y/null-ls.nvim/lua/null-ls/helpers/generator_factory.lua:320: spawning command "pylint" at /home/amit with args { "--from-stdin", "/home/amit/test.py", "-f", "json" } [TRACE Sat 29 Apr 2023 12:59:31 PM IST] ...y/null-ls.nvim/lua/null-ls/helpers/generator_factory.lua:204: error output: nil [TRACE Sat 29 Apr 2023 12:59:31 PM IST] ...y/null-ls.nvim/lua/null-ls/helpers/generator_factory.lua:205: output: [ { "type": "error", "module": "test", "obj": "", "line": 4, "column": 0, "endLine": 4, "endColumn": 19, "path": "test.py", "symbol": "import-error", "message": "Unable to import 'pandas'", "message-id": "E0401" }, { "type": "error", "module": "test", "obj": "", "line": 5, "column": 0, "endLine": 5, "endColumn": 15, "path": "test.py", "symbol": "import-error", "message": "Unable to import 'pysdafas'", "message-id": "E0401" }, { "type": "warning", "module": "test", "obj": "", "line": 25, "column": 0, "endLine": 25, "endColumn": 5, "path": "test.py", "symbol": "pointless-statement", "message": "Statement seems to have no effect", "message-id": "W0104" }, { "type": "error", "module": "test", "obj": "", "line": 25, "column": 0, "endLine": 25, "endColumn": 5, "path": "test.py", "symbol": "undefined-variable", "message": "Undefined variable 'dsfas'", "message-id": "E0602" }, { "type": "refactor", "module": "test", "obj": "", "line": 33, "column": 7, "endLine": 33, "endColumn": 32, "path": "test.py", "symbol": "use-dict-literal", "message": "Consider using '{"name": 'amit', "age": 45}' instead of a call to 'dict'.", "message-id": "R1735" }, { "type": "warning", "module": "test", "obj": "", "line": 5, "column": 0, "endLine": 5, "endColumn": 15, "path": "test.py", "symbol": "unused-import", "message": "Unused import pysdafas", "message-id": "W0611" } ]

[TRACE Sat 29 Apr 2023 12:59:31 PM IST] ...share/nvim/lazy/null-ls.nvim/lua/null-ls/diagnostics.lua:181: received diagnostics from source 5 [TRACE Sat 29 Apr 2023 12:59:31 PM IST] ...share/nvim/lazy/null-ls.nvim/lua/null-ls/diagnostics.lua:182: { { code = "E0401", col = 0, end_col = 19, end_lnum = 3, end_row = 4, lnum = 3, message = "Unable to import 'pandas'", message_id = "E0401", row = 4, severity = 1, source = "pylint", symbol = "import-error" }, { code = "E0401", col = 0, end_col = 15, end_lnum = 4, end_row = 5, lnum = 4, message = "Unable to import 'pysdafas'", message_id = "E0401", row = 5, severity = 1, source = "pylint", symbol = "import-error" }, { code = "W0104", col = 0, end_col = 5, end_lnum = 24, end_row = 25, lnum = 24, message = "Statement seems to have no effect", message_id = "W0104", row = 25, severity = 2, source = "pylint", symbol = "pointless-statement" }, { code = "E0602", col = 0, end_col = 5, end_lnum = 24, end_row = 25, lnum = 24, message = "Undefined variable 'dsfas'", message_id = "E0602", row = 25, severity = 1, source = "pylint", symbol = "undefined-variable" }, { code = "R1735", col = 7, end_col = 32, end_lnum = 32, end_row = 33, lnum = 32, message = "Consider using '{"name": 'amit', "age": 45}' instead of a call to 'dict'.", message_id = "R1735", row = 33, severity = 3, source = "pylint", symbol = "use-dict-literal" }, { code = "W0611", col = 0, end_col = 15, end_lnum = 4, end_row = 5, lnum = 4, message = "Unused import pysdafas", message_id = "W0611", row = 5, severity = 2, source = "pylint", symbol = "unused-import" } }

Help

Yes

Implementation Help

No response

Requirements

  • [X] I have read and followed the instructions above and understand that my issue will be closed if I did not provide the required information.

caamittiwari avatar Apr 29 '23 07:04 caamittiwari

Do you get the same error when you run pylint from the command line? If you can clean up your issue formatting and follow the template I can investigate further.

jose-elias-alvarez avatar May 05 '23 20:05 jose-elias-alvarez

code is working fine and if i run pylint from command line its work prefectly there no import error however i dont why import error highlight for third party packages

caamittiwari avatar May 07 '23 10:05 caamittiwari

Same problem here...

bitzcoder avatar Jun 12 '23 16:06 bitzcoder