Skip to content

Conversation

@ytc338
Copy link
Contributor

@ytc338 ytc338 commented Jan 2, 2026

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_similarity function 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/*.py and pre-commit run mypy --files pyrit/analytics/*.py
with --strict in pre-commit args.

@ytc338
Copy link
Contributor Author

ytc338 commented Jan 2, 2026

@microsoft-github-policy-service agree

Copy link
Contributor

@romanlutz romanlutz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@romanlutz romanlutz self-assigned this Jan 3, 2026
@ytc338
Copy link
Contributor Author

ytc338 commented Jan 3, 2026

Great I'll keep working on other modules and add an extra hook in pre-commit-config.

@romanlutz romanlutz merged commit f9c6ba5 into Azure:main Jan 7, 2026
20 checks passed
@romanlutz romanlutz mentioned this pull request Jan 7, 2026
20 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants