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

Skip to content

IsADirectoryError for namespace packages when using --linecoverage-report #18128

Description

@AAriam

Crash Report

This is similar to #15979:

For namespace packages, e.g., when a package contains a data directory without any Python files, IsADirectoryError is raised when using the --linecoverage-report option. This happens when using the --package option, but not when passing the directory path.

Traceback

version: 1.13.0
Traceback (most recent call last):
  File "/Users/home/mambaforge/envs/test-mypy/bin/mypy", line 8, in <module>
    sys.exit(console_entry())
             ~~~~~~~~~~~~~^^
  File "/Users/home/mambaforge/envs/test-mypy/lib/python3.13/site-packages/mypy/__main__.py", line 15, in console_entry
    main()
    ~~~~^^
  File "mypy/main.py", line 102, in main
  File "mypy/main.py", line 186, in run_build
  File "mypy/build.py", line 194, in build
  File "mypy/build.py", line 269, in _build
  File "mypy/build.py", line 2935, in dispatch
  File "mypy/build.py", line 3333, in process_graph
  File "mypy/build.py", line 3438, in process_stale_scc
  File "mypy/build.py", line 2397, in finish_passes
  File "mypy/build.py", line 873, in report_file
  File "mypy/report.py", line 91, in file
  File "mypy/report.py", line 426, in on_file
IsADirectoryError: [Errno 21] Is a directory: '/Users/home/mambaforge/envs/test-mypy/lib/python3.13/site-packages/test_package/data'

To Reproduce

  1. Create a package:
.
├── src/
│   └── test_package/
│       ├── data/
│       │   └── test.txt
│       ├── __init__.py
│       └── py.typed
└── pyproject.toml

with pyproject.toml:

[project]
name = "test_package"
version = "0.0.0"

[build-system]
requires = ["setuptools >= 72.1.0"]
build-backend = "setuptools.build_meta"

[tool]
[tool.setuptools]
include-package-data = true

[tool.setuptools.packages.find]
where = ["src"]
namespaces = true
  1. Install the package: pip install .
  2. Run mypy: mypy --package test_package --linecoverage-report . --raise-exceptions

Your Environment

  • Mypy version used: mypy 1.13.0 (compiled: yes)
  • Mypy command-line flags: --package, --linecoverage-report, --raise-exceptions
  • Python version used: 3.13.0
  • Operating system and version: macOS 13.7

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions