@@ -50,6 +50,7 @@ def test_import_stdlib_validations(input_source: str, expected_output: list[str]
5050 [item [2 ].split (" " )[0 ] for item in CommunityOfPythonFlake8Plugin (ast .parse (input_source )).run ()] # noqa: COP011
5151 ) == sorted (expected_output )
5252
53+
5354@pytest .mark .skip ("disabled" )
5455@pytest .mark .parametrize (
5556 ("input_source" , "expected_output" ),
@@ -161,6 +162,41 @@ def test_type_annotation_validations(input_source: str, expected_output: list[st
161162 "import pytest\n @pytest.fixture(name='events')\n def fixture_events() -> list[dict]:\n return []" ,
162163 [],
163164 ),
165+ # No violation: property decorator should exempt function from COP009 (but not COP007 for name length)
166+ (
167+ "class ExampleClass:\n @property\n def calculator(): pass" ,
168+ ["COP012" ],
169+ ),
170+ # No violation: property() decorator call should exempt function from COP009 (but not COP007)
171+ (
172+ "class ExampleClass:\n @property()\n def calculator(): pass" ,
173+ ["COP012" ],
174+ ),
175+ # No violation: cached_property decorator should exempt function from COP009 (but not COP007)
176+ (
177+ "import functools\n class ExampleClass:\n @functools.cached_property\n def calculator(): pass" ,
178+ ["COP012" ],
179+ ),
180+ # No violation: cached_property() decorator call should exempt function from COP009 (but not COP007)
181+ (
182+ "import functools\n class ExampleClass:\n @functools.cached_property()\n def calculator(): pass" ,
183+ ["COP012" ],
184+ ),
185+ # No violation: ModelFactory methods should be exempt from COP009
186+ (
187+ "from polyfactory.factories.pydantic_factory import ModelFactory\n class MyFactory(ModelFactory):\n def calculator(self): pass" ,
188+ ["COP012" ],
189+ ),
190+ # No violation: cached_property imported directly should exempt function from COP009 (but triggers COP002 for import style)
191+ (
192+ "from functools import cached_property\n class ExampleClass:\n @cached_property\n def calculator(self): pass" ,
193+ ["COP002" , "COP012" ],
194+ ),
195+ # No violation: cached_property() imported directly should exempt function from COP009 (but triggers COP002)
196+ (
197+ "from functools import cached_property\n class ExampleClass:\n @cached_property()\n def calculator(self): pass" ,
198+ ["COP002" , "COP012" ],
199+ ),
164200 # No violation: pytest fixture with name parameter should be exempt from COP009
165201 (
166202 "import pytest\n @pytest.fixture(name='events')\n def fixture_events() -> list[dict]:\n return []" ,
0 commit comments