Skip to content

Dependency with dashed distribution-name is marked as unused if there is a folder with its import name in the repository #505

@LordFckHelmchen

Description

@LordFckHelmchen

Describe the bug
When a package with a dashed distribution name (e.g. nats-py) is used in a repository that contains a subpackage with the same name as the import name (e.g. nats), fawltydeps reports the dependency as unused although it is used.

To Reproduce

  1. Create a repository with the following structure:
    pyproject.toml  # Project config
    src             # Source folder
     |-- main.py    # Contains the import
     |-- nats       # Empty folder
    
  2. Add the following minimal content to pyproject.toml:
    [project]
    name = "test"
    version = "0.1.0"
    requires-python = ">=3.13.2"
    dependencies = ["nats-py"
  3. Add the following content to the main.py:
    import nats
    print(f"{nats=}")
  4. Initialize a local .venv & verify that the program is working and it correctly imports the package:
    > python src/main.py
    nats=<module 'nats' from '.../test/.venv/Lib/site-packages/nats/__init__.py'>
  5. Run fawltydeps on the project

Expected behavior

No undeclared or unused dependencies detected.

Observed behavior

These dependencies appear to be unused (i.e. not imported):
- 'nats-py'

For a more verbose report re-run with the `--detailed` option.

Environment

  • Windows 11
  • FawltyDeps v0.20.0

Additional context

Also tested with other packages, nats is only an example

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions