Thanks to visit codestin.com
Credit goes to github.com

Skip to content

--html-report cannot be used with namespace-packages, explicit-package-bases and -p: IsADirectoryError #11334

Description

@earshinov

Example repo

To Reproduce

$ git clone https://github.com/earshinov/mypy-htmlreport-isadirectoryerror.git
$ cd mypy-htmlreport-isadirectoryerror

...and follow the instructions from README.

In short, the problem is an IsADirectoryError when trying to pass both -p and --html-report:

$ poetry run mypy -p folder --html-report=mypy-report --show-traceback
/mnt/c/tmp/mypy-bug/folder/subfolder: error: INTERNAL ERROR -- Please try using mypy master on Github:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 0.910
Traceback (most recent call last):
  File "/home/user/.cache/pypoetry/virtualenvs/mypy-bug-3PnpPrM--py3.8/bin/mypy", line 8, in <module>
    sys.exit(console_entry())
  File "mypy/build.py", line 1955, in wrap_context
  File "mypy/build.py", line 2205, in finish_passes
  File "mypy/build.py", line 818, in report_file
  File "mypy/report.py", line 83, in file
  File "mypy/report.py", line 482, in on_file
  File "mypy/report.py", line 131, in iterate_python_lines
  File "/usr/lib/python3.8/tokenize.py", line 392, in open
    buffer = _builtin_open(filename, 'rb')
IsADirectoryError: [Errno 21] Is a directory: 'folder/subfolder'
/mnt/c/tmp/mypy-bug/folder/subfolder: : note: use --pdb to drop into pdb
Generated HTML report (via XSLT): /mnt/c/tmp/mypy-bug/mypy-report/index.html

Expected Behavior

It should be possible to use -p and --html-report together.

Actual Behavior

-p and --html-report used together cause an IsADirectoryError.

Your Environment

  • Windows 10 / WSL / Ubuntu 20.04
  • Python 3.8.10
  • mypy 0.910

Reproducible with mypy@master (a114826) as well.

mypy.ini:

[mypy]
explicit_package_bases = True
ignore_missing_imports = True
namespace_packages = True
# As recommended in PEP-484
# - https://github.com/python/typing/issues/275
# - https://www.python.org/dev/peps/pep-0484/#union-types
no_implicit_optional = True
show_column_numbers = True
show_error_codes = True
strict = True

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions