astral-sh / rye

a Hassle-Free Python Experience
https://rye.astral.sh
MIT License
13.6k stars 466 forks source link

Working around incompatiblity with `mypy`'s `explicit-package-bases` #1246

Closed jamesbraza closed 2 months ago

jamesbraza commented 2 months ago

Steps to Reproduce

I have a Rye project where my toolchain includes https://github.com/dosisod/refurb. I am using refurb==2.0.0.

Running rye run refurb ., I get error: Source file found twice under different module names.

I have traced it to be because of the --explicit-package-bases argument that refurb passes to mypy: https://github.com/dosisod/refurb/blob/v2.0.0/refurb/main.py#L141

I guess I am wondering, is there anything I can do to work around this?


 .
├──  src
│  └──  package
│     ├──  __init__.py
│     ├──  foo.py
│     ├──  py.typed
│     └──  version.py
├──  tests
│  ├──  paper.pdf
│  └──  test_foo.py
├──  pyproject.toml
├──  README.md
├──  requirements-dev.lock
└──  requirements.lock

Expected Result

Rye structure can work with rye run refurb .

Actual Result

> rye run refurb .
src/package/__init__.py: error: Source file found twice under different module names: "src.package" and "package"
>  rye run refurb src tests
src/package/__init__.py: error: Source file found twice under different module names: "src.package" and "package"
> rye run refurb src/package tests
src/package/__init__.py: error: Source file found twice under different module names: "src.package" and "package"

Version Info

rye 0.36.0 commit: 0.36.0 (2024-07-07) platform: macos (aarch64) self-python: cpython@3.12.3 symlink support: true uv enabled: true

Stacktrace

No response

jamesbraza commented 2 months ago

I realized this is a permutation of https://github.com/dosisod/refurb/issues/246, and can be worked around by:

rye run refurb -- . --exclude=src.package

If there's nothing else to be done here, feel free to close this out