Title: Fix tool-usage detection for shared deps & declare `tomli` for `pyproject-fmt` by nathanjmcdougall · Pull Request #1948 · usethis-python/usethis-python · GitHub
Open Graph Title: Fix tool-usage detection for shared deps & declare `tomli` for `pyproject-fmt` by nathanjmcdougall · Pull Request #1948 · usethis-python/usethis-python
X Title: Fix tool-usage detection for shared deps & declare `tomli` for `pyproject-fmt` by nathanjmcdougall · Pull Request #1948 · usethis-python/usethis-python
Description: Summary
This is a bug fix with two related parts.
1. Declare tomli for pyproject-fmt on Python < 3.11
Since pyproject-fmt v2.22.0, the vendored toml-fmt-common does import tomli internally on Python < 3.11 but no longer declares tomli as a dependency. usethis tool pyproject-fmt therefore produced a ModuleNotFoundError when run on Python < 3.11.
PyprojectFmtToolSpec.deps_by_group() now conditionally includes tomli for Python < 3.11 projects (based on requires-python, falling back to the running interpreter), mirroring the existing CodespellToolSpec pattern.
2. Don't treat a shared supporting dependency as identifying a tool
Adding tomli to pyproject-fmt exposed a pre-existing bug. ToolSpec.is_declared_as_dep() treats every dependency a tool declares as a "characteristic" dependency — i.e. evidence (via is_used()) that the tool is in use:
return any(
is_dep_in_any_group(dep)
for dep in self.get_dep_group_deps(unconditional=True)
)
But tomli is a supporting dependency shared between tools, not characteristic of any one of them. This was already wrong for codespell — tomli was never an identifying/characteristic dependency of codespell. It was simply unobservable while codespell was the only tool declaring tomli: nothing else claimed tomli, so the false positive never fired.
Once pyproject-fmt also declared tomli, the two tools began cross-triggering each other's is_used(): declaring tomli for one made the other report as used (and vice versa). This surfaced as spurious ☐ Run 'uv run
Open Graph Description: Summary This is a bug fix with two related parts. 1. Declare tomli for pyproject-fmt on Python < 3.11 Since pyproject-fmt v2.22.0, the vendored toml-fmt-common does import tomli internally on Py...
X Description: Summary This is a bug fix with two related parts. 1. Declare tomli for pyproject-fmt on Python < 3.11 Since pyproject-fmt v2.22.0, the vendored toml-fmt-common does import tomli internally o...
Opengraph URL: https://github.com/usethis-python/usethis-python/pull/1948
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:38a98e4b-be49-7663-77f6-a3f90d9c66c1 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | CB42:3C7B0B:13A3853:1AA6AC9:6A4D72EF |
| html-safe-nonce | 604bc2091c0448d4190693b2e84ba6e813cbbaf4856e8e6d480c0617caa1d34d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQjQyOjNDN0IwQjoxM0EzODUzOjFBQTZBQzk6NkE0RDcyRUYiLCJ2aXNpdG9yX2lkIjoiOTEzNjMyNjQ2NDczMTE4MTgwNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 9179d610bb46e7b65ecd418fa86d1918b646342d75bd9235a2b4e3a74895bb70 |
| hovercard-subject-tag | pull_request:3785220882 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/usethis-python/usethis-python/pull/1948/files |
| twitter:image | https://avatars.githubusercontent.com/u/18602289?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/18602289?s=400&v=4 |
| og:image:alt | Summary This is a bug fix with two related parts. 1. Declare tomli for pyproject-fmt on Python < 3.11 Since pyproject-fmt v2.22.0, the vendored toml-fmt-common does import tomli internally on Py... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | c78260c7b3f4ac4b0356c8208537f05406a3a2d46a9ec3f735b372dcc519c39e |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/usethis-python/usethis-python git https://github.com/usethis-python/usethis-python.git |
| octolytics-dimension-user_id | 216362695 |
| octolytics-dimension-user_login | usethis-python |
| octolytics-dimension-repository_id | 842189705 |
| octolytics-dimension-repository_nwo | usethis-python/usethis-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 842189705 |
| octolytics-dimension-repository_network_root_nwo | usethis-python/usethis-python |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 399fff412f48461d435721c009efc17ea44be72f |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width