pypa / readme_renderer

Safely render long_description/README files in Warehouse
Apache License 2.0
158 stars 88 forks source link

Skip installing the package when type linting #313

Closed kurtmckee closed 6 days ago

kurtmckee commented 1 week ago

Mypy is configured to scan the source directory, not the installed package. Therefore, this PR configures tox to skip package installation.

On my machine, this change reduces the mypy tox run from 2.79 seconds to 0.25 seconds.

kurtmckee commented 6 days ago

Rebased on main

miketheman commented 6 days ago

This appears to be failing as the runtime dependency nh3 is not being installed, and it contains the type hints that mypy is looking for. Is there another way to tell tox to install the package deps without installing the package itself?

kurtmckee commented 6 days ago

Fascinating. Installing the package allows the dependencies to be available for mypy. On my machine, the cached mypy tox environment wasn't recreated when making this change, so the dependencies were still available and didn't trigger an error. Now that it's running in a clean environment in CI, the test is failing.

I'm closing this, as it's currently necessary to install the package to get the package dependencies that mypy wants to also have installed.

kurtmckee commented 6 days ago

@miketheman We were typing at the same time. :smile:

I don't know of a way to get the dependencies in a supported -- and non-duplicative -- way from within tox.

Tox supports deps, and nh3 et al could be added there manually, but that adds a risk of administrative burden to maintain dependencies in pyproject.toml and tox.ini.

The environment setup times will be less costly if #308 merges.