You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
mypy inspects the field names instead of looking at the signature of __new__.
(I didn't try __init__, that wasn't my use case.)
Mypy 0.610, Python 3.6.3.
Not tried Mypy from git master (haven't checked how to do that).
Code:
#! /usr/bin/env python3fromtypingimportList, NamedTupleclassCommand(NamedTuple):
subcommands: List[str]
classHelpCommand(Command):
def__new__(cls):
returnCommand.__new__(cls, subcommands=[])
HelpCommand() # fails in mypy, works in PythonHelpCommand(subcommands=[]) # works in mypy, fails in Python
Command: python3 -m mypy typetest.py
Output:
typetest.py:12: error: Too few arguments for "HelpCommand"
Python has a different idea about what should work and what shouldn't:
$ ./typetest.py
Traceback (most recent call last):
File "./typetest.py", line 12, in <module>
HelpCommand(subcommands=[]) # works
TypeError: __new__() got an unexpected keyword argument 'subcommands'
The text was updated successfully, but these errors were encountered:
mypy inspects the field names instead of looking at the signature of
__new__
.(I didn't try
__init__
, that wasn't my use case.)Mypy 0.610, Python 3.6.3.
Not tried Mypy from git master (haven't checked how to do that).
Code:
Command:
python3 -m mypy typetest.py
Output:
Python has a different idea about what should work and what shouldn't:
The text was updated successfully, but these errors were encountered: