This issue encapsulates a few related issues that need to be cleaned up in the code base. @jared321 please add a comment of I've missed anything. I think this issue can document the ongoing design discussion related to type hinting and documentation. Currently, I've chosen to use type hinting throughout, as I find it to be useful as a developer when looking at unfamiliar code. However, as pointed out by @jared321, the current type hinting is not always consistent with a) the documentation and b) the actual code. An example of this is in _run_frescox_simulation.py, where type hinting for the parameters filename and cwd suggest they must be pathlib.Path objects, the documentation suggests they can be Path or str objects, and the code is consistent with the documentation, ensuring they must be one of those two types.
This raises the question, should the code not accept any type that can be converted into a Path object (e.g. Path, str, some type fromos.path, etc)? Perhaps, rather than explicitly type checking, we should simply check that the conversion to Path works, and then go on to use the Path object in the code (as we do currently).
If this is what we decide upon, this complicates the type hinting. One solution would be something like this:
from typing import Union
from os import PathLike
PathLikeType = Union[str, bytes, PathLike[str], PathLike[bytes]]
But, IMO, this starts getting complicated. Additionally, there is the issue of _run_frescox_simulation being a low-level, internal function, with each package exposing it via a more limited interface bfrescox(pro).run_simulation, which should consistently hint and document shared arguments, but may provide, for example, defaults that don't exist in the lower level function.
This issue is for discussion on what the guidelines are for type hinting and type-related documentation in the code. The resolution of this issue will be
- a clear policy on documentation and type hints included in the developer guide
- a consistent implementation of those policies throughout the codebase
This issue encapsulates a few related issues that need to be cleaned up in the code base. @jared321 please add a comment of I've missed anything. I think this issue can document the ongoing design discussion related to type hinting and documentation. Currently, I've chosen to use type hinting throughout, as I find it to be useful as a developer when looking at unfamiliar code. However, as pointed out by @jared321, the current type hinting is not always consistent with a) the documentation and b) the actual code. An example of this is in
_run_frescox_simulation.py, where type hinting for the parametersfilenameandcwdsuggest they must bepathlib.Pathobjects, the documentation suggests they can bePath or strobjects, and the code is consistent with the documentation, ensuring they must be one of those two types.This raises the question, should the code not accept any type that can be converted into a
Pathobject (e.g.Path,str, some type fromos.path, etc)? Perhaps, rather than explicitly type checking, we should simply check that the conversion toPathworks, and then go on to use thePathobject in the code (as we do currently).If this is what we decide upon, this complicates the type hinting. One solution would be something like this:
But, IMO, this starts getting complicated. Additionally, there is the issue of
_run_frescox_simulationbeing a low-level, internal function, with each package exposing it via a more limited interfacebfrescox(pro).run_simulation, which should consistently hint and document shared arguments, but may provide, for example, defaults that don't exist in the lower level function.This issue is for discussion on what the guidelines are for type hinting and type-related documentation in the code. The resolution of this issue will be