refactor_composer #535

Merged
sb10q merged 3 commits from refactor_composer into master 2024-11-27 16:26:36 +08:00
Collaborator

The current composer allows inheriting from classes defined later in program, so that the following code compiles:

from __future__ import annotations
class A(B):
    pass
class B:
    pass

After this PR, the above code will raise the exception: NameError: name 'B' is not defined (at src/test.py:3:9). This check only applies to the inheritance, and type annotations will still work i.e.

from __future__ import annotations
class A:
    a: B
class B:
    pass

This removes the possibility of cyclic inheritance and simplifies the process of finding all class ancestors. The PR also fixes up minor issues like disabling default value assignment to self i.e.

class A:
  def __init__(self=1):
    pass

and cleans up the method/field analysis part of class definition analysis.

The current composer allows inheriting from classes defined later in program, so that the following code compiles: ``` from __future__ import annotations class A(B): pass class B: pass ``` After this PR, the above code will raise the exception: `NameError: name 'B' is not defined (at src/test.py:3:9)`. This check only applies to the inheritance, and type annotations will still work i.e. ``` from __future__ import annotations class A: a: B class B: pass ``` This removes the possibility of cyclic inheritance and simplifies the process of finding all class ancestors. The PR also fixes up minor issues like disabling default value assignment to `self` i.e. ``` class A: def __init__(self=1): pass ``` and cleans up the method/field analysis part of class definition analysis.
derppening force-pushed refactor_composer from 5654190503 to 45ae761ed9 2024-10-04 15:14:21 +08:00 Compare
derppening force-pushed refactor_composer from 45ae761ed9 to 279a2014d2 2024-11-25 16:34:04 +08:00 Compare
derppening requested review from derppening 2024-11-26 16:20:58 +08:00
Collaborator

Note to self: Will review this tomorrow.

Note to self: Will review this tomorrow.
derppening force-pushed refactor_composer from 279a2014d2 to babc081dbd 2024-11-27 14:32:46 +08:00 Compare
derppening approved these changes 2024-11-27 14:33:18 +08:00
derppening requested review from sb10q 2024-11-27 14:33:22 +08:00
sb10q merged commit babc081dbd into master 2024-11-27 16:26:36 +08:00
sb10q deleted branch refactor_composer 2024-11-27 16:26:36 +08:00
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: M-Labs/nac3#535
No description provided.