ajwdewit / pcse

Repository for the Python Crop Simulation Environment
Other
184 stars 125 forks source link

Undefine names: delts --> delt and file --> cb_file #56

Closed cclauss closed 2 years ago

cclauss commented 2 years ago

Also, cmp() was removed in Python 3.

$ flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics

./pcse/doc/downloads/example_simobj.py:55:50: F821 undefined name 'delts'
        self.states.STATE2 += self.rates.RATE2 * delts
                                                 ^
./pcse/pcse/fileinput/cabo_weather.py:340:35: F821 undefined name 'file'
            raise PCSEError(msg % file)
                                  ^
./pcse/pcse/pydispatch/saferef.py:154:11: F821 undefined name 'cmp'
            return cmp( self.__class__, type(other) )
                   ^
./pcse/pcse/pydispatch/saferef.py:155:10: F821 undefined name 'cmp'
        return cmp( self.key, other.key)
               ^
4     F821 undefined name 'delts'
4

Flake8 F82 tests are almost always undefined names which are usually a sign of a typo, missing imports, using a variable before defining it, unused code, or code that has not been ported to Python 3. These would be compile-time errors in a compiled language but in Python, a NameError may be raised which may halt/crash the script on the user.

ajwdewit commented 2 years ago

Thanks for pointing out the problem with the cmp() function. I will have a look at it.