-
Notifications
You must be signed in to change notification settings - Fork 7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
devicetree: edtlib: support deepcopy and add type annotations #56849
Merged
mbolivar-nordic
merged 24 commits into
zephyrproject-rtos:main
from
mbolivar-nordic:edtlib-deepcopy-and-types
Apr 17, 2023
Merged
devicetree: edtlib: support deepcopy and add type annotations #56849
mbolivar-nordic
merged 24 commits into
zephyrproject-rtos:main
from
mbolivar-nordic:edtlib-deepcopy-and-types
Apr 17, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The reference is to an incorrect method. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This is still the preferred style in a zephyr DTS. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Move all the initial settings of instance attributes to the constructor, so we can keep track of them all more easily. No functional changes expected. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
9497bb2
to
ec5b6ba
Compare
Just like we did for dtlib in 15e3e31 ("dtlib: implement copy.deepcopy() for DT"), except this time it's for EDT. This also can do no harm and will be useful for implementing system devicetree support. No functional changes expected under the assumption that no users are relying on us having stashed the exact bindings_dirs list passed to the constructor. This patch switches to making a defensive copy, which is safer and makes implementing this a little cleaner. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This is just moving the class definition higher in the file. I am reordering the classes to make it possible to type annotate the module in a more readable way. Git might make the diff look bigger than it really is. To verify this is just moving code, use 'git diff --minimal'. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This is just moving the class definition higher in the file to make it easier to type annotate the module. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This is just moving the class definition higher in the file to make it easier to type annotate the module. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This is just moving the class definition higher in the file to make it easier to type annotate the module. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This is just moving the class definition higher in the file to make it easier to type annotate the module. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This is just moving the class definition higher in the file to make it easier to type annotate the module. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This is just moving the class definition higher in the file to make it easier to type annotate the module. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This is just moving the class definition higher in the file. I am reordering the classes to make it possible to type annotate the module in a more readable way. Git might make the diff look bigger than it really is. To verify this is just moving code, use 'git diff --minimal'. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Miscellaneous fixes discovered by inspection while type annotating the module. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Incremental progress towards type annotating the whole module. Annotate helper procedures used by the class as well. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Incremental progress towards type annotating the module. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
ec5b6ba
to
1505174
Compare
Converting this to a dataclass will make it easier to type annotate. Adding type annotations is incremental progress towards type checking the entire module. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Converting this to a dataclass will make it easier to type annotate. Adding type annotations is incremental progress towards type checking the entire module. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Fix grammar issues and typos. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Converting this to a dataclass will make it easier to type annotate. Adding type annotations is incremental progress towards type checking the entire module. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Converting this to a dataclass will make it easier to type annotate. Adding type annotations is incremental progress towards type checking the entire module. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Converting this to a dataclass will make it easier to type annotate. Adding type annotations is incremental progress towards type checking the entire module. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This requires adding a private constructor so that mypy can tell what all the final instance state is going to be. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Incremental progress towards type annotating the entire module. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This concludes the type annotations for the public API for the module, along with the relevant internal state. It's not worth type annotating the internal backwards compatibility shim for !include. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
nordicjm
approved these changes
Apr 17, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks okay
galak
approved these changes
Apr 17, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a standalone PR that will be needed to add system devicetree support.
After prototyping in #52272, it became clear that it makes sense to implement the sysdtlib.SysDT class we will use to implement system DT support as a subclass of edtlib.EDT. This is a change from making it a subclass of dtlib.DT as originally proposed.
Using edtlib instead means that we can have type-safe access to some properties in sysdtlib by writing bindings for system DT specific compatibles. It also helps when implementing requirements like accessing the proper number of cells in
reg
properties, which edtlib knows, but dtlib doesn't. (We need address/size cell counts in order to be able to decode theaddress-map
properties in CPU cluster nodes.)This PR does two things that we need to be able to safely do this subclassing:
EDT.__deepcopy__()
support, so that I can make a copy of the system devicetree, mutate it into a regular devicetree, and emit the mutated copyThere are a couple of cleanup commits at the beginning that I found along the way.