MCPcopy Create free account
hub / github.com/RustPython/RustPython / __new__

Method __new__

Lib/enum.py:1347–1366  ·  view source on GitHub ↗

values must already be of type `str`

(cls, *values)

Source from the content-addressed store, hash-verified

1345 """
1346
1347 def __new__(cls, *values):
1348 "values must already be of type `str`"
1349 if len(values) > 3:
1350 raise TypeError('too many arguments for str(): %r' % (values, ))
1351 if len(values) == 1:
1352 # it must be a string
1353 if not isinstance(values[0], str):
1354 raise TypeError('%r is not a string' % (values[0], ))
1355 if len(values) >= 2:
1356 # check that encoding argument is a string
1357 if not isinstance(values[1], str):
1358 raise TypeError('encoding must be a string, not %r' % (values[1], ))
1359 if len(values) == 3:
1360 # check that errors argument is a string
1361 if not isinstance(values[2], str):
1362 raise TypeError('errors must be a string, not %r' % (values[2]))
1363 value = str(*values)
1364 member = str.__new__(cls, value)
1365 member._value_ = value
1366 return member
1367
1368 @staticmethod
1369 def _generate_next_value_(name, start, count, last_values):

Callers

nothing calls this directly

Calls 4

lenFunction · 0.85
isinstanceFunction · 0.85
strFunction · 0.85
__new__Method · 0.45

Tested by

no test coverage detected