py_trees icon indicating copy to clipboard operation
py_trees copied to clipboard

class Composite should explicitly declare current_child type

Open jbcpollak opened this issue 3 years ago • 2 comments

class Composite should be declared as:

class Composite(behaviour.Behaviour):
    current_child: Optional[Behaviour]

otherwise current_child is typed as None according to the Composite.init method.

jbcpollak avatar Jun 01 '21 15:06 jbcpollak

update: I discovered this happens with the mypy rule check_untyped_defs = True enabled in a project. I'm going to look more into that rule and if it can be tweaked on a per-dependency basis.

jbcpollak avatar Jun 02 '21 21:06 jbcpollak

looking into the check_untyped_defs option, I definitely think its ideal to enable, and it does warn about this problem, as well as others. I can make a PR to clean up the errors it causes.

https://mypy.readthedocs.io/en/stable/config_file.html#confval-check_untyped_defs

jbcpollak avatar Jun 02 '21 21:06 jbcpollak

Thanks for the heads up!

Fixed in #380.

stonier avatar Jan 22 '23 06:01 stonier