python / python/mypy

Namespace packages supported by default?

Open
#14,057 7 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

I notice in the changelog that 0.990 adds support for namespace packages by default.

I've been using mypy on namespace packages (jaraco, svg, backports, and others) for some time now (https://github.com/jaraco/skeleton/commit/7455f2f25310b2d778a648e45d32033ccc790946).

With the release of mypy 0.990, however, tests have started failing across all projects with namespace packages:

error: Source file found twice under different module names: "collections" and "jaraco.collections"

The change log indicates that 0.990 adds support for namespace packages by default. Annoyingly, this change has had the opposite effect for my projects. I find that I can restore functionality by adding explicit_package_bases = True to the config file (or equivalent command line). It's slightly annoying to have to add this configuration to all of my projects just to support some projects with namespace packages.

Is it possible that explicit package bases will become default in the future?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the mypy 0.990 changelog and the behavior of the explicit_package_bases configuration. Reproduce the duplicate-module error with a namespace-package project such as jaraco or backports, then determine the expected default behavior. Done would require a decided default and the affected namespace-package scenario passing or being clearly documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.