TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Is there a linter for Python "dependency definition files"?

1 pointsby niels_bomabout 1 year ago
In Python there are multiple file formats for defining dependencies:<p>- [`requirements.txt`](https:&#x2F;&#x2F;pip.pypa.io&#x2F;en&#x2F;stable&#x2F;reference&#x2F;requirements-file-format&#x2F;)<p>- [`Pipfile`](https:&#x2F;&#x2F;pipenv.pypa.io&#x2F;en&#x2F;latest&#x2F;pipfile.html)<p>- [`pyproject.toml`](&lt;https:&#x2F;&#x2F;packaging.python.org&#x2F;en&#x2F;latest&#x2F;specifications&#x2F;pyproject-toml&#x2F;&gt;)<p>Let&#x27;s call these &quot;dependency definition files&quot;, even though some do more than just that.<p>I think in general it&#x27;s a good idea to pin versions of your dependencies when you&#x27;re building an application, it&#x27;s different for libraries. My question is not about whether or not this is a good idea.<p>These dependency definition files allow for defining non-specific versions of those dependencies. For example: `cowsay &gt;= 4.0`.<p>In my applications I&#x27;d like to force and remind myself to <i>only</i> create pinned dependencies. Ideally there would be a linter and git pre-commit hook so that I&#x27;m warned and blocked from creating dependencies that are not pinned.<p>In the JavaScript world there&#x27;s a linter for `package.json` files that does exactly what I want: - [the tool](https:&#x2F;&#x2F;npmpackagejsonlint.org&#x2F;) - [the rule](https:&#x2F;&#x2F;npmpackagejsonlint.org&#x2F;docs&#x2F;rules&#x2F;dependencies&#x2F;prefer-absolute-version-dependencies&#x2F;)<p>Do tools like this exist for Python?

2 comments

stop50about 1 year ago
For the requirements.txt there is usually a so called freeze file that has the frozen dependencies in it.
评论 #39547196 未加载
MstWntdabout 1 year ago
micomamba is pretty great.. its fast and it&#x27;s repo is the same as conda.. it handles dependency resolution pretty fast too.. only down side I can is that all packages are on pip.. most are available via conda.. but if your packages are in conda or any repo&#x2F;channel that micomamba can assess then you are all set..