refactor_composer #535

Open
abdul124 wants to merge 3 commits from refactor_composer into master
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
This pull request has changes conflicting with the target branch.
  • nac3core/src/toplevel/composer.rs
You can also view command line instructions.

Step 1:

From your project repository, check out a new branch and test the changes.
git checkout -b refactor_composer master
git pull origin refactor_composer

Step 2:

Merge the changes and update on Gitea.
git checkout master
git merge --no-ff refactor_composer
git push origin master
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.