MCPcopy Index your code
hub / github.com/RustPython/RustPython / __new__

Method __new__

Lib/_pydatetime.py:2406–2419  ·  view source on GitHub ↗
(cls, offset, name=_Omitted)

Source from the content-addressed store, hash-verified

2404 # Sentinel value to disallow None
2405 _Omitted = object()
2406 def __new__(cls, offset, name=_Omitted):
2407 if not isinstance(offset, timedelta):
2408 raise TypeError("offset must be a timedelta")
2409 if name is cls._Omitted:
2410 if not offset:
2411 return cls.utc
2412 name = None
2413 elif not isinstance(name, str):
2414 raise TypeError("name must be a string")
2415 if not cls._minoffset <= offset <= cls._maxoffset:
2416 raise ValueError("offset must be a timedelta "
2417 "strictly between -timedelta(hours=24) and "
2418 f"timedelta(hours=24), not {offset!r}")
2419 return cls._create(offset, name)
2420
2421 def __init_subclass__(cls):
2422 raise TypeError("type 'datetime.timezone' is not an acceptable base type")

Callers

nothing calls this directly

Calls 2

isinstanceFunction · 0.85
_createMethod · 0.45

Tested by

no test coverage detected