Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

find_digit is not defined in Pylance – PYTHON

class TimeUtil():

def calculate_seconds(self, input):
    if any(x in input.lower() for x in ['weeks', 'week','wks','wk']):
        return (int(find_digit(self, input))*604800)        
    elif any(x in input.lower() for x in ['days', 'day']):
        return (int(find_digit(self, input))*86400)
    elif any(x in input.lower() for x in ['hours', 'hour','hr','hrs']):
        return (int(find_digit(self, input))*3600)
    elif any(x in input.lower() for x in ['minutes', 'minute','min','mins']):
        return (int(find_digit(self, input))*60)
    elif any(x in input.lower() for x in ['seconds', 'second','sec','secs']):
        return (int(find_digit(self, input))*60)
    else:
        return -1

def find_digit(self, text):
    return ''.join(input for input in text if input.isdigit())

By calling find_digit method in another method calculate_seconds I could see the error as "find_digit is not defined Pylance (reportUndefinedVaribale)"

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

I noticed that the way your calling find_digit() is like that:

find_digit(self, input)

You probably meant to write it like that:

TimeUtil.find_digit(self, input)

but you should write it like that because it’s more readable:

self.find_digit(input)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading