Skip to content

-2 and --python-version 2.7 arguments differ in behaviour #5576

@sqwishy

Description

@sqwishy

This is on mypy 0.620 on Python 3.6.

My understanding is that the command arguments -2 and --python-version 2.7 are
supposed to do the same thing. But in infer_python_version_and_executable()
python_version is different on the given options and I think this affects how it finds a
value for python_executable.

If I'm understanding this correctly, I think it might be an issue with the arguments
having different dest values? -2 sets a constant on the wrong namespace?

> python3 -m pdb (which mypy) -2 .
> /home/sqwishy/.local/bin/mypy(4)<module>()
-> import re
(Pdb) b mypy/main.py:278
Breakpoint 1 at /home/sqwishy/.local/lib/python3.6/site-packages/mypy/main.py:278
(Pdb) c
> /home/sqwishy/.local/lib/python3.6/site-packages/mypy/main.py(278)infer_python_version_and_executable()
-> if special_opts.python_executable is not None and special_opts.python_version is not None:
(Pdb) pp vars(special_opts)
...
 'python_executable': None,
 'python_version': None,
 'silent_imports': False,
...
> python3 -m pdb (which mypy) --python-version 2.7 .
> /home/sqwishy/.local/bin/mypy(4)<module>()
-> import re
(Pdb) b mypy/main.py:278
Breakpoint 1 at /home/sqwishy/.local/lib/python3.6/site-packages/mypy/main.py:278
(Pdb) c
> /home/sqwishy/.local/lib/python3.6/site-packages/mypy/main.py(278)infer_python_version_and_executable()
-> if special_opts.python_executable is not None and special_opts.python_version is not None:
(Pdb) pp vars(special_opts)
...
 'python_executable': None,
 'python_version': (2, 7),
 'silent_imports': False,
...

I would expect special_opts.python_version to be the same in both cases.

Metadata

Metadata

Assignees

Labels

bugmypy got something wrong

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions