You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to open a discussion about whether bilby should adopt type hints, which have been part of the standard Python language since version 3.5.
Motivation
Type hints help in the following ways:
Improve code readability, where inputs and outputs are made explicit
Enable better static analysis, so problems can be caught before runtime
Auto-completion and documentation with IDEs
I've recently been using type hints a lot in my own personal workflow, and I have found that they significantly improve the quality of my code, as well as the development experience. I feel adding type-hint support to bilby would improve the package.
Practical considerations
Since bilby is a large and mature codebase, a full retrofit of type hints may not be practical in the short term. However, I think a gradual adoption strategy could work well. For instance, we could encourage contributors to include type hints in new pull requests and add them to the core interfaces and functionality.
In my own experience, it is typically sufficient to add type hints to
Function arguments and returns
Class attributes and methods
Iterables when they are initialised, for example, my_dict: dict[str, float] = {}
and then the linter is able to infer the rest of the types.
I'd be interested to know others' thoughts on this.
We discussed this on the last dev call in relation to #1110. The consensus was we'd like to add type hints. Given that, I think the next step is to make a plan for how to add them and decide which modules we should priortize. We may also need to set out some guidelines.
Activity
mj-will commentedon Aug 11, 2026
We discussed this on the last dev call in relation to #1110. The consensus was we'd like to add type hints. Given that, I think the next step is to make a plan for how to add them and decide which modules we should priortize. We may also need to set out some guidelines.