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
Shouldn't be too hard to fix, look at parse_namedtuple_args in semanal_namedtuple.py. Not sure if mypy's AST has the equivalent of inspect.Signature.bind, but that would make it really easy.
More than deprecated -- typing.NamedTuple now markes these as positional args only. But collections.namedtuple is unchanged. Not sure if there's anything actionable left here?
Yes, I'm not sure if mypy should support these keyword arguments for collections.namedtuple when typing.NamedTuple doesn't accept it...
Still, it might be a good idea to elaborate the error message like: error: mypy does not support keyword arguments 'typename' and 'field_names' for namedtuple()
Below code provides example:
MergeStrategy = NamedTuple(
typename="MergeStrategy",
fields=[("left", str), ("right", str), ("how", str), ("on", List[str])],
)
Generates error
{
"resource": <>,
"owner": "python",
"code": "error",
"severity": 8,
"message": "Unexpected arguments to namedtuple()",
"source": "mypy",
"startLineNumber": 53,
"startColumn": 18,
"endLineNumber": 53,
"endColumn": 18
}
whereas this does not:
MergeStrategy = NamedTuple(
"MergeStrategy", [("left", str), ("right", str), ("how", str), ("on", List[str])],
)
Same thing for regular namedtuple.
get same error with this:
MergeStrategy = namedtuple(typename="MergeStrategy", field_names=["left", "right", "how", "on"])
but this is fine:
MergeStrategy = namedtuple("MergeStrategy", ["left", "right", "how", "on"])
The text was updated successfully, but these errors were encountered: