0

I use VS Code as my IDE and I have Pylance extension to help debugging the code.

Pylance keeps underlining command=self.get_inputs as error even thought the code runs just fine. Here is an example:

self.button1 = ctk.CTkButton(self, text="Calculate", command=self.get_inputs) self.button1.grid(row=5, column=0, pady=10, padx=10, sticky="W")

def get_inputs(self):
    H1 = self.entry2.get()
    d1 = self.entry3.get()
    T = self.entry4.get()
    alpha1 = self.entry5.get()
    s = self.entry6.get()
    z = self.entry7.get()
    d2 = self.entry8.get()

    return H1, d1, T, alpha1, s, z, d2

Here is the full error: full error

I don't understand why this is happening. what can I do avoid getting this?

I don't know how I can avoid getting this type of error

  • Try adding type annotations to the method definition: `def get_inputs(self) -> None:` (this specifies that `get_inputs` has no `return` value, or more accurately, returns `None`) – JRiggles Jan 12 '23 at 15:44
  • get_inputs returns a bunch of variables, sorry I forgot to add that to the code, ill edit it now. – Said Lababidi Jan 12 '23 at 15:50
  • Ah! In that case, try annotating `def get_inputs(self) -> tuple[str, str, str, str, str, str, str]:`, or (perhaps less accurately, but less obnoxiously) `def get_inputs(self) -> tuple[str, ...]:`. I think what's happening here is that Pylance is mad about not having a return type annotation for this method. – JRiggles Jan 12 '23 at 16:22
  • 2
    Please don't post a picture of the error. Copy and paste the text into your question. – Bryan Oakley Jan 12 '23 at 16:26
  • None of these fixed the issue :/ – Said Lababidi Jan 12 '23 at 17:08
  • Does this help? tuple[[str, str, str, str], [str, str, str]] – toyota Supra Jan 13 '23 at 01:11

0 Answers0