Skip to content

Commit

Permalink
edtlib: finish adding type annotations
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
mbolivar-nordic committed Apr 17, 2023
1 parent 3318380 commit 5847890
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions scripts/dts/python-devicetree/src/devicetree/edtlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -3173,7 +3173,7 @@ class _BindingLoader(Loader):
# include/devicetree.h.
#

_DEFAULT_PROP_TYPES = {
_DEFAULT_PROP_TYPES: Dict[str, str] = {
"compatible": "string-array",
"status": "string",
"reg": "array",
Expand All @@ -3185,18 +3185,20 @@ class _BindingLoader(Loader):
"interrupt-controller": "boolean",
}

_STATUS_ENUM = "ok okay disabled reserved fail fail-sss".split()
_STATUS_ENUM: List[str] = "ok okay disabled reserved fail fail-sss".split()

def _raw_default_property_for(name):
ret = {
def _raw_default_property_for(
name: str
) -> Dict[str, Union[str, bool, List[str]]]:
ret: Dict[str, Union[str, bool, List[str]]] = {
'type': _DEFAULT_PROP_TYPES[name],
'required': False,
}
if name == 'status':
ret['enum'] = _STATUS_ENUM
return ret

_DEFAULT_PROP_BINDING = Binding(
_DEFAULT_PROP_BINDING: Binding = Binding(
None, {},
raw={
'properties': {
Expand All @@ -3207,14 +3209,14 @@ def _raw_default_property_for(name):
require_compatible=False, require_description=False,
)

_DEFAULT_PROP_SPECS = {
_DEFAULT_PROP_SPECS: Dict[str, PropertySpec] = {
name: PropertySpec(name, _DEFAULT_PROP_BINDING)
for name in _DEFAULT_PROP_TYPES
}

# A set of vendor prefixes which are grandfathered in by Linux,
# and therefore by us as well.
_VENDOR_PREFIX_ALLOWED = set([
_VENDOR_PREFIX_ALLOWED: Set[str] = set([
"at25", "bm", "devbus", "dmacap", "dsa",
"exynos", "fsia", "fsib", "gpio-fan", "gpio-key", "gpio", "gpmc",
"hdmi", "i2c-gpio", "keypad", "m25p", "max8952", "max8997",
Expand Down

0 comments on commit 5847890

Please sign in to comment.