Spaces:
Sleeping
Sleeping
File size: 643 Bytes
1719436 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
from typing import Any
def build_default_namespace() -> dict[str, Any]:
"""Creates a dictionary with types from the typing module and built-in types."""
import typing
from numbers import Number
from fractions import Fraction
namespace = {
name: getattr(typing, name) for name in dir(typing) if not name.startswith("_")
}
namespace.update(
{
"int": int,
"str": str,
"float": float,
"bool": bool,
"dict": dict,
"list": list,
}
)
namespace.update({"Fraction": Fraction, "Number": Number})
return namespace
|