Skip to content

Commit

Permalink
Define missing using an actual class
Browse files Browse the repository at this point in the history
  • Loading branch information
mattclay committed Oct 2, 2024
1 parent 0a87e81 commit d3dd9f2
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/jinja2/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,17 @@

F = t.TypeVar("F", bound=t.Callable[..., t.Any])

# special singleton representing missing values for the runtime
missing: t.Any = type(
"MissingType",
(),
{"__repr__": lambda x: "missing", "__reduce__": lambda x: "missing"},
)()

class _MissingType:
def __repr__(self) -> str:
return "missing"

def __reduce__(self) -> str:
return "missing"


missing: t.Any = _MissingType()
"""Special singleton representing missing values for the runtime."""

internal_code: t.MutableSet[CodeType] = set()

Expand Down

0 comments on commit d3dd9f2

Please sign in to comment.