MAINT: Enhance type hinting across auth and analytics modules #1300
Merged
romanlutz merged 8 commits intomicrosoft:mainfrom Jan 7, 2026
Merged
Conversation
…e cosine similarity robustness.
Contributor
Author
|
@microsoft-github-policy-service agree |
romanlutz
reviewed
Jan 2, 2026
Contributor
romanlutz
left a comment
There was a problem hiding this comment.
This is great! The result_analysis.py return types will probably change over time but for now it's accurate 🙂
I'm worried about people breaking this. Can we add an extra step to pre-commit config to run in strict mode for the modules that are done? Then every PR for the corresponding item #1272 can expand to further modules? Ideally, we'd exclude the same modules from the existing mypy check, of course, to avoid running it twice.
Contributor
Author
|
Great I'll keep working on other modules and add an extra hook in pre-commit-config. |
…e cosine similarity robustness.
…ype safety across common and memeory modules
…,-analytics-strict-mypy-checking-microsoft#1272
romanlutz
approved these changes
Jan 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Added type hints to various functions in auth and analytics. And added explicit cast to satisfy mypy.
#1272
@romanlutz
The only thing I think requires further notice is
cosine_similarityfunction in pyrit/analytics/conversation_analytics.py The type hint was this to return a np.ndarry. I looked into the reference the inputs are always 1D arrays so the return type is float. Let me know what do you think. Thanks.Tests and Documentation
The changes passed the
pre-commit run mypy --files pyrit/auth/*.pyandpre-commit run mypy --files pyrit/analytics/*.pywith
--strictin pre-commit args.