Skip to content

Reduce the use of typing.Any#1443

Merged
nathanjmcdougall merged 3 commits intomainfrom
refactor/reduce-typing-any
Mar 21, 2026
Merged

Reduce the use of typing.Any#1443
nathanjmcdougall merged 3 commits intomainfrom
refactor/reduce-typing-any

Conversation

@nathanjmcdougall
Copy link
Copy Markdown
Collaborator

Toward #1321

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 advances issue #1321 by tightening type annotations to reduce reliance on typing.Any, improving compatibility with stricter type-checking (e.g., enabling reportExplicitAny in basedpyright).

Changes:

  • Replaces several Any annotations with object, and widens list-typed parameters to Sequence where mutation isn’t required.
  • Refines tool/rule selection APIs to accept Sequence[Rule] rather than list[Rule].
  • Improves config file manager typing and adds a TOML guard for regex-based keys.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/usethis/test_init.py Replaces Any in test mocks with object.
tests/usethis/_tool/test_base.py Switches ignore comment style for assignment override in tests.
tests/usethis/_backend/uv/test_lockfile.py Replaces Any in test mocks with object.
src/usethis/_ui/interface/tool.py Removes Any import and narrows **kwargs typing to object.
src/usethis/_tool/impl/base/ruff.py Uses Sequence[Rule] for rule-ignoring API.
src/usethis/_tool/impl/base/deptry.py Uses Sequence[Rule] for (de)selection APIs.
src/usethis/_tool/config.py Replaces config callback return type from Any to object.
src/usethis/_tool/base.py Widens rule list parameters to Sequence[Rule].
src/usethis/_test.py Narrows invoke/invoke_safe extra kwargs to object and updates input typing.
src/usethis/_pipeweld/containers.py Replaces __eq__ parameter type from Any to object.
src/usethis/_io.py Replaces value types from Any to object for key/value manager write APIs; adds explicit pyright ignore for a necessary Any.
src/usethis/_file/yaml/update.py Refactors YAML list update typing to Sequence and adjusts helper signatures.
src/usethis/file/yaml/io.py Updates list APIs to accept Sequence and normalizes list concatenation.
src/usethis/file/toml/io.py Updates list APIs to accept Sequence, removes type-ignores, and adds regex-key guard.
src/usethis/_file/merge.py Refactors _deep_merge typing to be generic via TypeVar.
src/usethis/file/ini/io.py Replaces Any with object for values, adds runtime validation via TypeAdapter, and widens list APIs to Sequence.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 21, 2026

Merging this PR will not alter performance

✅ 2 untouched benchmarks


Comparing refactor/reduce-typing-any (50898b3) with main (19e5eff)

Open in CodSpeed

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 21, 2026

Codecov Report

❌ Patch coverage is 97.29730% with 1 line in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/usethis/_file/toml/io_.py 88.88% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@nathanjmcdougall nathanjmcdougall merged commit 6edd7ec into main Mar 21, 2026
20 checks passed
@nathanjmcdougall nathanjmcdougall deleted the refactor/reduce-typing-any branch March 21, 2026 23:09
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.

2 participants