Skip to content

Instantly share code, notes, and snippets.

@mypy-play
Created July 8, 2026 13:13
Show Gist options
  • Select an option

  • Save mypy-play/12656dc0a0ea91a4e2bc5288fcc1f2da to your computer and use it in GitHub Desktop.

Select an option

Save mypy-play/12656dc0a0ea91a4e2bc5288fcc1f2da to your computer and use it in GitHub Desktop.
Shared via mypy Playground
from dataclasses import dataclass
from typing import Any, NotRequired, Self, TypedDict
@dataclass
class BaseQueryParameters:
type: str
query: str
from_: int
size: int
def patch(self, query: str) -> Self:
"""Return a new instance with updated fields."""
return self.__class__(**{**self.__dict__, "query": query})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment