Skip to content

Conversation

@chbndrhnns
Copy link
Contributor

@chbndrhnns chbndrhnns commented Dec 15, 2025

Fixes https://youtrack.jetbrains.com/issue/PY-53074/Implement-abstract-methods-produces-syntax-error-for-async-methods


Note

Adjusts method insertion to handle classes without bodies (ensuring correct indentation, including async), and adds tests for nested indentation and abstract method order.

  • Implementation/Override logic:
    • Update writeMember in python/src/com/jetbrains/python/codeInsight/override/PyOverrideImplementUtil.java to build the function first and insert it via PyPsiRefactoringUtil.addElementToStatementList when no anchor is present, ensuring correct indentation for empty/nested class bodies (incl. async methods).
  • Tests:
    • Add ImplementAbstractNestedIndentation.py and _after.py to verify correct indentation when implementing async methods in nested classes.
    • Extend ImplementAbstractOrder.py and _after.py to include foo2 and validate implementation order.
    • Add testImplementAbstractNestedIndentation in PyQuickFixTest.kt; keep testImplementAbstractOrder updated.

Written by Cursor Bugbot for commit 8dcae90. This will update automatically on new commits. Configure here.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Test data missing abstract method in after file

The ImplementAbstractOrder.py test file adds @abstractmethod def foo2(self) to the Abstract class, but ImplementAbstractOrder_after.py is missing this same abstract method definition in the Abstract class. The Abstract class should be identical in both files since the "implement methods" operation only modifies the subclass Foo, not the base class. This test data inconsistency will cause the test to fail or produce misleading results.

python/testData/inspections/ImplementAbstractOrder_after.py#L13-L15

python/testData/inspections/ImplementAbstractOrder.py#L14-L17

@abstractmethod
def foo2(self):
pass

Fix in Cursor Fix in Web


@lancelote lancelote requested a review from avokin2 December 15, 2025 22:42
@BartvHelvert BartvHelvert added the PyCharm Pull requests for PyCharm label Dec 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PyCharm Pull requests for PyCharm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants