Case 1: Class is coded in code.py. Say class contains a couple of instance variables and an instance method that does some processing and returns the result. In flask endpoint, I am importing the class from code.py module and instantiating the class and calling the object.mtdname()
Case 2: in code.py, along with the same class as in case 1, I define a function (do_work) outside the class. The do_work function instantiates the class and calls object.mtdname() method. In flask endpoint, I import only the do_work function from code.py. when do_work is invoked it will create the object and return the result.
What are pro and cons of using case 1 or 2?
Generally speaking, I would prefer case 1 because case 2 requires an additional test that really doesn't test anything new.  So for the purposes of reducing code, I would go with Case 1 unless do_work did something other than just call the one method.
Instantiate class and call its functions via a function in the same module as class declaration?