ADR suggestion: New code should use type hints #3170
Replies: 9 comments 10 replies
-
|
If we implement ruff as in #3171, this might happen automatically... |
Beta Was this translation helpful? Give feedback.
-
|
For consistency we should probably use annotations on the function/method definition rather than type comments below the definition. @DrPaulSharp to create ruff PRs that modify this for both sasview and sasmodels. |
Beta Was this translation helpful? Give feedback.
-
|
Here is the proposed ADR for type hinting. Type hinting style guidePreamblePython is a dynamically typed programming language, so variables passed to and used in modules and classes may be of any value type at run-time. To minimize issues related to type mismatch, a base type-hinting structure is proposed. ProposalAdding type hints
Type hint structure
Type hint review process
|
Beta Was this translation helpful? Give feedback.
-
|
All of this looks good. I'd particularly emphasise the importance of using built-in types rather than the |
Beta Was this translation helpful? Give feedback.
-
|
As mentioned in the email to developers, this ADR was brought up for final approval at the October 7th meeting. The number of people on the call at the time of this discussion was relatively small. However, those remaining raised concerns that this requires a lot more thought than is evidenced in the discussion so far. In particular, this ADR will have an immediate high impact on developers and could adversely affect the current effort to broaden the contributor base. Specific points raised:
RECOMMENDATION: |
Beta Was this translation helpful? Give feedback.
-
|
Two suggested changes from the technical meeting on Dec. 12, 2025 to soften the requirements:
|
Beta Was this translation helpful? Give feedback.
-
|
Here is the final ADR proposal for type hinting. Type hinting style guidePreamblePython is a dynamically typed programming language, so variables passed to and used in modules and classes may be of any value type at run-time. To minimize issues related to type mismatch, a base type-hinting structure is proposed. ProposalAdding type hints
Type hint structure
Type hint review process
|
Beta Was this translation helpful? Give feedback.
-
|
This suggestion has been approved with the proposed changes and @krzywon will write up the final ADR. |
Beta Was this translation helpful? Give feedback.
-
|
This has been finalized in #3877. Closing. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
As discussed during the code camp (07/01/2025) we are trying to move towards having type-hints in the code.
Before addressing the bulk of the code, we should start requiring all the new code to contain type hints for all method signatures.
Checking type hints should also be a part of the code review.
Beta Was this translation helpful? Give feedback.
All reactions