Skip to content

Instantly share code, notes, and snippets.

@mypy-play
Created December 7, 2025 13:15
Show Gist options
  • Select an option

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

Select an option

Save mypy-play/d0d5de9a216936fd220dd091ee7a7e3e to your computer and use it in GitHub Desktop.
Shared via mypy Playground
# Welcome to the Pyrefly Sandbox, this is a page
# where you can write, share and learn about typing in Python.
#
# Here are a couple features of this sandbox:
# - Get real-time type checking feedback
# - Use reveal_type() to inspect inferred types
# - experiment with the IDE features that we support (e.g. autocomplete, go-to-definition, hover, etc)
# - Write and run Python code directly in your browser
from typing import *
from dataclasses import dataclass, replace
@dataclass
class Foo:
x: int
y: str
f = Foo(1, "a")
replace(f, x="wrong") # expect type error
replace(f, z=3) # expect type error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment