Open
Description
🐛 Bug Report
DefaultNamedArg
may cause signature compatibility errors. Observed when a function has a default keyword argument in signature and is passed to be used as a function without that particular keyword argument.
To Reproduce
from typing import List, AnyStr
from glob import glob
import itertools as it
def expand_patterns(
pats: List[AnyStr],
sort=True
):
paths = it.chain(map(glob, pats))
# Argument 1 to "map" has incompatible type "Callable[[AnyStr, DefaultNamedArg(bool, 'recursive')], List[AnyStr]]"; expected "Callable[[AnyStr], List[AnyStr]]"
if sort:
paths = sorted(paths)
return paths
Expected Behavior
Not sure if this ought to happen, but I'd expect a function like foo(x: int, y='y')
to be peacefully passable to a function expecting Callable[[int], Any]
.
Actual Behavior
# Argument 1 to "map" has incompatible type "Callable[[AnyStr, DefaultNamedArg(bool, 'recursive')], List[AnyStr]]"; expected "Callable[[AnyStr], List[AnyStr]]"
Your Environment
- Mypy version used: 0.782
- Mypy command-line flags: Default of VSCode
- Mypy configuration options from
mypy.ini
(and other config files): N/A - Python version used: 3.7.7
- Operating system and version: Windows 10, 2004