seals icon indicating copy to clipboard operation
seals copied to clipboard

Strange non-type-error

Open dfilan opened this issue 2 years ago • 3 comments

In base_envs.py, the class TabularModelPOMDP has a method obs_dtype that returns the data type of observation vectors - specifically, it returns self.observation_matrix.dtype. However, it is typed as returning an int. When I run code checks without first having first activated the virtual environment, mypy reports a type error. However, when I first activate the virtual environment, mypy doesn't complain at all. At first glance, this would certainly appear to be a type error, but maybe it isn't for some reason?

dfilan avatar Jan 17 '23 22:01 dfilan

You are correct, this appears to be an error, and it is concerning that mypy doesn't catch this in a consistent way. I'll look into this. Could you provide some more context for this difference in behavior?

Rocamonde avatar Jan 20 '23 15:01 Rocamonde

My 'default' mypy version before activating a virtual environment is 0.971, and that gives the error src/seals/base_envs.py:412: error: Incompatible return value type (got "dtype[Any]", expected "int"). When I build the virtual environment by running ./ci/build_venv.sh, activate it, and run pip install -e .[dev], mypy now has version 0.991, and when I run it on src/seals/base_envs.py I just get Success: no issues found in 1 source file. Whether or not the virtual environment is activated, the python version is 3.8.13.

LMK if there's other context that would be useful.

dfilan avatar Jan 20 '23 19:01 dfilan

That said, if I update mypy to 0.991 outside the virtual environment and run it on src/seals/base_envs.py I get the same error, so it must be something other than the mypy version.

dfilan avatar Jan 20 '23 19:01 dfilan