From 60c78f1fbe7c9da20d2294b46c3c540d518d105a Mon Sep 17 00:00:00 2001 From: Nathan McDougall Date: Sat, 21 Feb 2026 06:41:19 +1300 Subject: [PATCH] Enable `reportArgumentType` in `basedpyright` I'm removing a couple of the tests which aren't adding value since the type checker already protects against errors. --- pyproject.toml | 1 - src/usethis/_file/toml/io_.py | 2 +- tests/usethis/_file/ini/test_ini_io_.py | 21 ------------------- .../_integrations/pre_commit/test_yaml.py | 7 ------- 4 files changed, 1 insertion(+), 30 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 61eba4b9..4e65de64 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -208,7 +208,6 @@ rules.possibly-missing-attribute = "ignore" ignore = [ "src/usethis/_version.py" ] failOnWarnings = true reportAny = false -reportArgumentType = false reportAssignmentType = false reportAttributeAccessIssue = false reportCallInDefaultInitializer = false diff --git a/src/usethis/_file/toml/io_.py b/src/usethis/_file/toml/io_.py index 6305f682..3900bce7 100644 --- a/src/usethis/_file/toml/io_.py +++ b/src/usethis/_file/toml/io_.py @@ -402,7 +402,7 @@ def _set_value_in_existing( for key in reversed(unshared_keys[1:]): contents = {key: contents} - shared_container[keys[1]] = contents # type: ignore[reportAssignmentType] + shared_container[keys[1]] = contents # pyright: ignore[reportArgumentType] else: shared_container[_get_unified_key(unshared_keys)] = value diff --git a/tests/usethis/_file/ini/test_ini_io_.py b/tests/usethis/_file/ini/test_ini_io_.py index dd99b957..52e64ece 100644 --- a/tests/usethis/_file/ini/test_ini_io_.py +++ b/tests/usethis/_file/ini/test_ini_io_.py @@ -11,7 +11,6 @@ INIStructureError, INIValueAlreadySetError, INIValueMissingError, - InvalidINITypeError, UnexpectedINIIOError, UnexpectedINIOpenError, ) @@ -1471,26 +1470,6 @@ def relative_path(self) -> Path: """ ) - def test_wrong_list_type_raises(self, tmp_path: Path): - # Arrange - class MyINIFileManager(INIFileManager): - @property - def relative_path(self) -> Path: - return Path("valid.ini") - - valid_file = tmp_path / "valid.ini" - valid_file.touch() - - # Act, Assert - with ( - change_cwd(tmp_path), - MyINIFileManager() as manager, - pytest.raises( - InvalidINITypeError, match="INI files only support strings" - ), - ): - manager.extend_list(keys=["section", "key"], values=[123]) # type: ignore - class TestRemoveFromList: def test_singleton_list_collapsed(self, tmp_path: Path): # Arrange diff --git a/tests/usethis/_integrations/pre_commit/test_yaml.py b/tests/usethis/_integrations/pre_commit/test_yaml.py index 0ec8ec72..ef5c4c42 100644 --- a/tests/usethis/_integrations/pre_commit/test_yaml.py +++ b/tests/usethis/_integrations/pre_commit/test_yaml.py @@ -148,10 +148,3 @@ def test_placeholder(self, tmp_path: Path): ), reference={}, ) - - def test_invalid(self): - with pytest.raises(TypeError): - _pre_commit_fancy_dump( - config=2, # type: ignore for test - reference={}, - )