-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
bugmypy got something wrongmypy got something wrong
Description
This issue is occurring with Debian GNU/Linux 9.8 (stretch)
, Python 3.7.2
, and mypy 0.680+dev.3cea8326d5fbc67030316ccc4addc4297af6daaa
. Here is a script to reproduce it:
#!/bin/bash
CAT=$(which cat)
mkdir mypy_path_test
cd mypy_path_test
mkdir --parents packages/a
touch packages/a/__init__.py
git clone https://github.com/python/mypy.git
cd mypy
git submodule init
git submodule update
cd ..
python3 -m venv .virtualenv
source .virtualenv/bin/activate
pip3 install --upgrade ./mypy
echo "python version:" $(python3 --version)
echo "mypy version:" $(mypy --version)
echo ""
echo "MYPYPATH works:"
MYPYPATH=packages/ mypy --package a
echo ""
echo "mypy_path doesn't work:"
$CAT << EOF > mypy.ini
[mypy]
mypy_path = packages/
EOF
mypy --package a
Output (after the installation):
python version: Python 3.7.2
mypy version: mypy 0.680+dev.3cea8326d5fbc67030316ccc4addc4297af6daaa
MYPYPATH works:
mypy_path doesn't work:
Can't find package 'a'
mypy
finds the package when MYPYPATH
is given as an environment variable but not when mypy_path
is given in mypy.ini
. As best I can tell, here's what happens:
main.main
callsmain.process_options
main.process_options
callsmain.process_config_file
- finding that a
--package
argument has been given,main.process_options
callsmodulefinder.mypy_path
modulefinder.mypy_path
gets the path fromMYPYPATH
andmain.process_options
never usesoptions.mypy_path
I can remedy the problem with the following change:
@@ -781,7 +781,9 @@ def process_options(args: List[str],
# Set target.
if special_opts.modules + special_opts.packages:
options.build_type = BuildType.MODULE
- search_paths = SearchPaths((os.getcwd(),), tuple(mypy_path()), (), ())
+ search_paths = SearchPaths(
+ (os.getcwd(),), tuple(mypy_path() + options.mypy_path), (), ()
+ )
targets = []
# TODO: use the same cache that the BuildManager will
cache = FindModuleCache(search_paths, fscache)
If this is not expected behavior and this change is all that's needed, I am happy to make a pull request.
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrong