Use __getitem__ -> object instead of __getitem__ -> Any in FileManagers#1439
Merged
nathanjmcdougall merged 5 commits intomainfrom Mar 21, 2026
Merged
Use __getitem__ -> object instead of __getitem__ -> Any in FileManagers#1439nathanjmcdougall merged 5 commits intomainfrom
__getitem__ -> object instead of __getitem__ -> Any in FileManagers#1439nathanjmcdougall merged 5 commits intomainfrom
Conversation
…anager`s Partly toward #1303, this should also improve the intelligibility of type issues via runtime validation messages
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens typing around config file access by changing KeyValueFileManager.__getitem__ to return object instead of Any, and updates affected call sites/tests to explicitly validate/narrow retrieved values (supporting the effort to enable reportAny in basedpyright per #1303).
Changes:
- Change
KeyValueFileManager.__getitem__(and TOML/YAML/INI implementations) return type fromAnytoobject. - Update tests and runtime code to narrow config values via
pydantic.TypeAdapter.validate_python(...). - Update some test writes to
PyprojectTOMLManagerto use direct key-path assignment (mgr[[..., ...]] = ...) and enablelint.future-annotationsin Ruff config.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/usethis/test_deps.py | Validate default-groups reads as list[str] via TypeAdapter. |
| tests/usethis/_ui/interface/test_tool.py | Validate per-file-ignores read is a dict before asserting on keys. |
| tests/usethis/_ui/interface/test_interface_ci.py | Use nested-key assignment for requires-python. |
| tests/usethis/_tool/impl/base/test_pytest.py | Use nested-key assignment for requires-python. |
| tests/usethis/_core/test_status.py | Validate project.classifiers as list[str] for membership checks. |
| tests/usethis/_core/test_core_tool.py | Validate TOML reads (default-groups, per-file-ignores rules) via TypeAdapter. |
| tests/usethis/_core/test_core_ci.py | Use nested-key assignment for requires-python. |
| src/usethis/_io.py | Change abstract __getitem__ return type to object. |
| src/usethis/_integrations/sonarqube/config.py | Validate SonarQube project key as str via TypeAdapter. |
| src/usethis/file/yaml/io.py | Update YAML manager __getitem__ return type to object. |
| src/usethis/file/toml/io.py | Update TOML manager __getitem__ return type to object. |
| src/usethis/file/ini/io.py | Update INI manager __getitem__ return type to object. |
| src/usethis/_core/status.py | Validate project.classifiers read as list[str] via TypeAdapter. |
| pyproject.toml | Enable lint.future-annotations; minor formatting cleanup. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Partly toward #1303, this should also improve the intelligibility of type issues via runtime validation messages