Skip to content

Conversation

@sbobryshev
Copy link

Switch to immutable types and add typing.Final for constants per PEP 591

Motivation and Context

Using immutable structures like tuples with Literal types allows for more precise type checking.
Instead of a generic list[str], which only indicates a list of strings, the new approach infers specific literal values (e.g., tuple[Literal['2024-11-05'], Literal['2025-03-26'], Literal['2025-06-18']]).

How Has This Been Tested?

uv run pyright

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Copy link
Contributor

@felixweinberger felixweinberger left a comment

Choose a reason for hiding this comment

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

Hi @sbobryshev thank you for this suggestion.

I'm not sure these annotations add much value on variables that are already clearly intended as global variables by their CAPITAL_CASE. (FYI this PR also misses an instance in client/session.py)

While this ensures immutability of those constants, it's a lot of ceremony for relatively little gain. I'm open to it though if other maintainers strongly believe this adds value (cc: @Kludex @dsp-ant)

@Kludex
Copy link
Member

Kludex commented Sep 26, 2025

This is technically correct, but I find this noisy.

You can quickly merge or close it. It's up to you. 🤷‍♂️

@felixweinberger
Copy link
Contributor

This is technically correct, but I find this noisy.

You can quickly merge or close it. It's up to you. 🤷‍♂️

Same here - I'd prefer not introducing this.

@sbobryshev sbobryshev deleted the add-typing-final-to-constants branch September 26, 2025 15:39
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.

3 participants