Skip to content

Use __getitem__ -> object instead of __getitem__ -> Any in FileManagers#1439

Merged
nathanjmcdougall merged 5 commits intomainfrom
feature/return-object-from-getitem
Mar 21, 2026
Merged

Use __getitem__ -> object instead of __getitem__ -> Any in FileManagers#1439
nathanjmcdougall merged 5 commits intomainfrom
feature/return-object-from-getitem

Conversation

@nathanjmcdougall
Copy link
Copy Markdown
Collaborator

Partly toward #1303, this should also improve the intelligibility of type issues via runtime validation messages

…anager`s

Partly toward #1303, this should also improve the intelligibility of type issues via runtime validation messages
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 20, 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!

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 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 from Any to object.
  • Update tests and runtime code to narrow config values via pydantic.TypeAdapter.validate_python(...).
  • Update some test writes to PyprojectTOMLManager to use direct key-path assignment (mgr[[..., ...]] = ...) and enable lint.future-annotations in 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.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 20, 2026

Merging this PR will not alter performance

✅ 2 untouched benchmarks


Comparing feature/return-object-from-getitem (6a85826) with main (cdf9b3a)

Open in CodSpeed

@nathanjmcdougall nathanjmcdougall merged commit df419a5 into main Mar 21, 2026
19 checks passed
@nathanjmcdougall nathanjmcdougall deleted the feature/return-object-from-getitem branch March 21, 2026 01:57
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