From 00ff3a47c21b8d3ff7cf54b77f14f49f0fa34e95 Mon Sep 17 00:00:00 2001 From: Nathan McDougall Date: Sat, 21 Feb 2026 06:58:21 +1300 Subject: [PATCH] Enable `reportAttributeAccessIssue` in basedpyright --- pyproject.toml | 1 - tests/usethis/_file/ini/test_ini_io_.py | 2 +- tests/usethis/_file/toml/test_toml_io_.py | 6 ++++-- tests/usethis/_python/test_version.py | 9 --------- tests/usethis/_tool/test_base.py | 21 ++++++++++++--------- 5 files changed, 17 insertions(+), 22 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 61eba4b9..0dcd842e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -210,7 +210,6 @@ failOnWarnings = true reportAny = false reportArgumentType = false reportAssignmentType = false -reportAttributeAccessIssue = false reportCallInDefaultInitializer = false reportExplicitAny = false reportImplicitOverride = false diff --git a/tests/usethis/_file/ini/test_ini_io_.py b/tests/usethis/_file/ini/test_ini_io_.py index dd99b957..a9ed50dd 100644 --- a/tests/usethis/_file/ini/test_ini_io_.py +++ b/tests/usethis/_file/ini/test_ini_io_.py @@ -103,7 +103,7 @@ def relative_path(self) -> Path: change_cwd(tmp_path), MyINIFileManager() as manager, ): - manager._content = 42 # type: ignore + manager._content = ConfigUpdater() with pytest.raises(UnexpectedINIIOError): manager.read_file() diff --git a/tests/usethis/_file/toml/test_toml_io_.py b/tests/usethis/_file/toml/test_toml_io_.py index 11a062f5..91df34d6 100644 --- a/tests/usethis/_file/toml/test_toml_io_.py +++ b/tests/usethis/_file/toml/test_toml_io_.py @@ -122,11 +122,13 @@ def relative_path(self) -> Path: with change_cwd(tmp_path): manager = MyTOMLFileManager() + expected = tomlkit.TOMLDocument() + # Act - manager._content = 42 # type: ignore + manager._content = expected # Assert - assert manager._content == 42 + assert manager._content == expected def test_set_high_levels_of_nesting(self, tmp_path: Path) -> None: # Arrange diff --git a/tests/usethis/_python/test_version.py b/tests/usethis/_python/test_version.py index 94fb5c68..b27b3322 100644 --- a/tests/usethis/_python/test_version.py +++ b/tests/usethis/_python/test_version.py @@ -199,12 +199,3 @@ def test_unequal_patch(self): # Act & Assert assert v1 != v2 - - class TestImmutability: - def test_frozen_dataclass(self): - # Arrange - version = PythonVersion(major="3", minor="13") - - # Act & Assert - with pytest.raises(AttributeError): - version.major = "4" # type: ignore[misc] diff --git a/tests/usethis/_tool/test_base.py b/tests/usethis/_tool/test_base.py index 1f76c9a3..a151c09b 100644 --- a/tests/usethis/_tool/test_base.py +++ b/tests/usethis/_tool/test_base.py @@ -1424,9 +1424,9 @@ def test_tool_without_selection_support(self) -> None: file_manager = MagicMock() tool = MockToolForRuleTests(file_manager=file_manager, selected_rules=[]) # Override to simulate a tool without selection support - tool._get_select_keys = lambda fm: super( # type: ignore[method-assign] + tool._get_select_keys = lambda file_manager: super( # type: ignore[method-assign] MockToolForRuleTests, tool - )._get_select_keys(fm) + )._get_select_keys(file_manager) # Act & Assert with pytest.raises( @@ -1489,13 +1489,16 @@ def test_it_returns_false(self) -> None: def test_tool_without_selection_support(self) -> None: # Arrange file_manager = MagicMock() - tool = MockToolForRuleTests( - file_manager=file_manager, selected_rules=["E501"] - ) - # Override to simulate a tool without selection support - tool._get_select_keys = lambda fm: super( # type: ignore[method-assign] - MockToolForRuleTests, tool - )._get_select_keys(fm) + + class MyMock(MockToolForRuleTests): + def _get_select_keys( + self, file_manager: KeyValueFileManager + ) -> list[str]: + return super(MockToolForRuleTests, self)._get_select_keys( + file_manager + ) + + tool = MyMock(file_manager=file_manager, selected_rules=["E501"]) # Act & Assert with pytest.raises(