Skip to content

Conditionally include tomli as a codespell dep based on Python version#1277

Merged
nathanjmcdougall merged 4 commits intomainfrom
1259-codespell-needs-tomli-as-a-dev-dep-for-python-311
Jan 6, 2026
Merged

Conditionally include tomli as a codespell dep based on Python version#1277
nathanjmcdougall merged 4 commits intomainfrom
1259-codespell-needs-tomli-as-a-dev-dep-for-python-311

Conversation

@nathanjmcdougall
Copy link
Copy Markdown
Collaborator

No description provided.

@nathanjmcdougall nathanjmcdougall linked an issue Jan 6, 2026 that may be closed by this pull request
@codecov
Copy link
Copy Markdown

codecov bot commented Jan 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Jan 6, 2026

CodSpeed Performance Report

Merging #1277 will not alter performance

Comparing 1259-codespell-needs-tomli-as-a-dev-dep-for-python-311 (4bf3753) with main (c003b45)

Summary

✅ 2 untouched

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modifies the codespell tool integration to conditionally include the tomli dependency based on the Python version. Since Python 3.11+ includes tomllib in the standard library, tomli is only needed for Python versions below 3.11. The logic checks the project's requires-python field or falls back to the interpreter version to determine whether to include tomli as a dependency.

Key changes:

  • Updated CodespellTool.get_dev_deps() to conditionally include tomli based on Python version requirements
  • Modified tests to dynamically check the interpreter version and adjust expected output accordingly
  • Added comprehensive test coverage for various requires-python scenarios

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/usethis/_tool/impl/codespell.py Added logic to conditionally include tomli dependency based on Python version
tests/usethis/_tool/impl/test_codespell.py Added test suite for get_dev_deps method covering various Python version scenarios
tests/usethis/_ui/interface/test_spellcheck.py Updated tests to dynamically check interpreter version and adjust expected output
tests/usethis/_ui/interface/test_init.py Updated test to conditionally expect tomli in output based on interpreter version
tests/usethis/_core/test_core_tool.py Updated tests to check interpreter version and adjust expected dependency messages

@nathanjmcdougall nathanjmcdougall merged commit 606e586 into main Jan 6, 2026
19 checks passed
@nathanjmcdougall nathanjmcdougall deleted the 1259-codespell-needs-tomli-as-a-dev-dep-for-python-311 branch January 6, 2026 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Codespell needs tomli as a dev dep for Python < 3.11

2 participants