@@ -1653,81 +1653,20 @@ class Employee(NamedTuple):
16531653 """
16541654 _root = True
16551655
1656- def __new__ (* args , ** kwargs ):
1657- if not args :
1658- raise TypeError ('NamedTuple.__new__(): not enough arguments' )
1659- cls , * args = args # allow the "cls" keyword be passed
1660- if args :
1661- typename , * args = args # allow the "typename" keyword be passed
1662- elif 'typename' in kwargs :
1663- typename = kwargs .pop ('typename' )
1664- import warnings
1665- warnings .warn ("Passing 'typename' as keyword argument is deprecated" ,
1666- DeprecationWarning , stacklevel = 2 )
1667- else :
1668- raise TypeError ("NamedTuple.__new__() missing 1 required positional "
1669- "argument: 'typename'" )
1670- if args :
1671- try :
1672- fields , = args # allow the "fields" keyword be passed
1673- except ValueError :
1674- raise TypeError (f'NamedTuple.__new__() takes from 2 to 3 '
1675- f'positional arguments but { len (args ) + 2 } '
1676- f'were given' ) from None
1677- elif 'fields' in kwargs and len (kwargs ) == 1 :
1678- fields = kwargs .pop ('fields' )
1679- import warnings
1680- warnings .warn ("Passing 'fields' as keyword argument is deprecated" ,
1681- DeprecationWarning , stacklevel = 2 )
1682- else :
1683- fields = None
1684-
1656+ def __new__ (cls , typename , fields = None , / , ** kwargs ):
16851657 if fields is None :
16861658 fields = kwargs .items ()
16871659 elif kwargs :
16881660 raise TypeError ("Either list of fields or keywords"
16891661 " can be provided to NamedTuple, not both" )
16901662 return _make_nmtuple (typename , fields )
1691- __new__ .__text_signature__ = '($cls, typename, fields=None, /, **kwargs)'
16921663
16931664
1694- def _dict_new (* args , ** kwargs ):
1695- if not args :
1696- raise TypeError ('TypedDict.__new__(): not enough arguments' )
1697- cls , * args = args # allow the "cls" keyword be passed
1665+ def _dict_new (cls , / , * args , ** kwargs ):
16981666 return dict (* args , ** kwargs )
1699- _dict_new .__text_signature__ = '($cls, _typename, _fields=None, /, **kwargs)'
1700-
1701-
1702- def _typeddict_new (* args , total = True , ** kwargs ):
1703- if not args :
1704- raise TypeError ('TypedDict.__new__(): not enough arguments' )
1705- cls , * args = args # allow the "cls" keyword be passed
1706- if args :
1707- typename , * args = args # allow the "_typename" keyword be passed
1708- elif '_typename' in kwargs :
1709- typename = kwargs .pop ('_typename' )
1710- import warnings
1711- warnings .warn ("Passing '_typename' as keyword argument is deprecated" ,
1712- DeprecationWarning , stacklevel = 2 )
1713- else :
1714- raise TypeError ("TypedDict.__new__() missing 1 required positional "
1715- "argument: '_typename'" )
1716- if args :
1717- try :
1718- fields , = args # allow the "_fields" keyword be passed
1719- except ValueError :
1720- raise TypeError (f'TypedDict.__new__() takes from 2 to 3 '
1721- f'positional arguments but { len (args ) + 2 } '
1722- f'were given' ) from None
1723- elif '_fields' in kwargs and len (kwargs ) == 1 :
1724- fields = kwargs .pop ('_fields' )
1725- import warnings
1726- warnings .warn ("Passing '_fields' as keyword argument is deprecated" ,
1727- DeprecationWarning , stacklevel = 2 )
1728- else :
1729- fields = None
17301667
1668+
1669+ def _typeddict_new (cls , typename , fields = None , / , * , total = True , ** kwargs ):
17311670 if fields is None :
17321671 fields = kwargs
17331672 elif kwargs :
@@ -1742,7 +1681,6 @@ def _typeddict_new(*args, total=True, **kwargs):
17421681 pass
17431682
17441683 return _TypedDictMeta (typename , (), ns )
1745- _typeddict_new .__text_signature__ = '($cls, _typename, _fields=None, /, *, total=True, **kwargs)'
17461684
17471685
17481686def _check_fails (cls , other ):
0 commit comments