GreenDelta / olca-ipc.py

Mozilla Public License 2.0
29 stars 17 forks source link

Roll back to `typing.List` and improve package typing #19

Closed Miguel-g-c closed 2 years ago

Miguel-g-c commented 2 years ago

Roll back to typing.List usage instead of standard lib generics. This way, Python version requirement is 3.6+ instead of 3.9+.

Also, yaml.load(input) method from pyyaml is deprecated and produces an error in last version. So this PR changes that for yaml.full_load(input). More info here: https://github.com/yaml/pyyaml/wiki/PyYAML-yaml.load(input)-Deprecation

Furthermore, this PR improves typing of some Client methods to enhance developer experience:

Previous behaviour

Methods such as get or get_all were typed as returning RootEntity objects. Therefore, some attributes and autocomplete features were missed:

Screen Shot 2021-12-10 at 13 26 41 Screen Shot 2021-12-10 at 13 27 03

New behaviour

Now, these methods are typed using a generic TypeVar, so the returned object will be of the correct type if a class is used as model_type parameter. This will improve user experience adding autocomplete, more accurate typing, etc:

Screen Shot 2021-12-10 at 13 28 25 Screen Shot 2021-12-10 at 13 28 48